#include <windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd
)
{
HWND hwnd;
MSG msg;
char lpszClassName[]="窗口";
WNDCLASS wc;
wc.style=0;
wc.lpfnWndProc=WndProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName=NULL;
wc.lpszClassName=lpszClassName;
RegisterClass(&wc);
hwnd=CreateWindow(
lpszClassName,
"windows",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hwnd,nShowCmd);
UpdateWindow(hwnd);
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;//好像是判断代表你这个程序是否获取过消息
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
//int wmId,wmEvent;
switch (message){
/*case WM_COMMAND:
wmId=LOWORD(wParam);
wmEvent=HIWORD(wParam);
switch (wmId)
{
case IDM_ABOUT:
DialogBox(_hInst,"ABOUTBOX",hWnd,(DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return (DefWindowProc(hWnd,message,wParam,lParam));
}
break;
*/
case WM_DESTROY:
//PostQuitMessage(0); //该函数会返回一个wm_quit消息进入线程列队中等待getmessage抓到它在退出程序
break;
case WM_LBUTTONDOWN:
MessageBox(hWnd,"hello",0,0);
break;
/*case WM_CLOSE: //所谓的屏蔽close
break;
*/default:
return DefWindowProc(hWnd,message,wParam,lParam);
}
return 0;
}