📄 main.cpp
字号:
#include"PreDef.h"
TCHAR appname[55];
TCHAR wndname[55];
INT mouse_x,mouse_y,mouse_l,mouse_r,mouse_ld,mouse_rd,mouse_lu,mouse_ru;
INT disinput;
RECT mouserect;
ATOM WndClsReg(HINSTANCE hinst);
LRESULT WINAPI WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam);
int WINAPI WinMain(HINSTANCE hinst,HINSTANCE hpreinst,LPTSTR szCmdLine,INT nCmdShow)
{
HWND hwnd;
MSG msg;
LoadString(hinst,IDS_APPNAME,appname,sizeof(appname)/sizeof(TCHAR));
LoadString(hinst,IDS_WNDNAME,wndname,sizeof(appname)/sizeof(TCHAR));
WndClsReg(hinst);
hwnd=CreateWindow(
__T(appname),
__T(wndname),
WS_CAPTION|WS_OVERLAPPED|WS_MINIMIZEBOX|WS_SYSMENU,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
GetDesktopWindow(),
NULL,
hinst,
NULL);
//ShowWindow(hwnd,SW_SHOW);
UpdateWindow(hwnd);
Init(hwnd);
PeekMessage(&msg,NULL,0,0,PM_NOREMOVE);
while(msg.message!=WM_QUIT)
{
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
GameMain(hwnd);
mouse_ld=0,mouse_rd=0,mouse_lu=0,mouse_ru=0;
//Sleep(1);
}
}
AppRelease();
UnregisterClass(__T(appname),hinst);
return (int)msg.wParam;
}
ATOM WndClsReg(HINSTANCE hinst)
{
WNDCLASSEX wce;
wce.cbClsExtra=0l;
wce.cbSize=sizeof(WNDCLASSEX);
wce.cbWndExtra=0l;
wce.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wce.hCursor=LoadCursor(NULL,IDC_ARROW);
wce.hIcon=LoadIcon(hinst,MAKEINTRESOURCE(IDI_APPICON));
wce.hIconSm=LoadIcon(hinst,MAKEINTRESOURCE(IDI_APPICON));
wce.hInstance=hinst;
wce.lpfnWndProc=&WndProc;
wce.lpszClassName=__T(appname);
wce.lpszMenuName=NULL;
wce.style=CS_VREDRAW|CS_HREDRAW|CS_OWNDC;
return RegisterClassEx(&wce);
}
LRESULT WINAPI WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
{
switch(message)
{
case WM_CREATE:
return 0;
case WM_ACTIVATE:
if(HIWORD(wparam)!=0||LOWORD(wparam)==WA_INACTIVE)
disinput=1;
else
disinput=0;
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_MOUSEMOVE:
mouse_x=LOWORD(lparam);
mouse_y=HIWORD(lparam);
return 0;
case WM_LBUTTONDOWN:
mouse_l=1;
mouse_ld=1;
return 0;
case WM_LBUTTONUP:
mouse_l=0;
mouse_lu=1;
return 0;
case WM_RBUTTONDOWN:
mouse_r=1;
mouse_rd=1;
return 0;
case WM_RBUTTONUP:
mouse_r=0;
mouse_ru=1;
return 0;
}
return DefWindowProc(hwnd,message,wparam,lparam);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -