#include <windows.h>
LRESULT CALLBACK WinProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch (msg){
case WM_DESTROY:
{
PostQuitMessage(0);
}
break;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT)
{
//注册窗口类
WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, WinProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"Demo", NULL};
RegisterClassEx(&wc);
//建立窗口
HWND hWnd = CreateWindow("Demo", "Demo",
WS_OVERLAPPEDWINDOW | WS_POPUP | WS_VISIBLE /*|WS_THICKFRAME*/,
GetSystemMetrics(SM_CXSCREEN)/3,
GetSystemMetrics(SM_CYSCREEN)/3,
GetSystemMetrics(SM_CXSCREEN)/3,
GetSystemMetrics(SM_CYSCREEN)/3,
NULL, NULL, wc.hInstance, NULL);
//显示窗口
ShowWindow(hWnd, SW_SHOWDEFAULT);
UpdateWindow(hWnd);
//获取消息
MSG msg;
BOOL bMessage;
PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);
while (msg.message != WM_QUIT){
bMessage = PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE);
if (bMessage){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
UnregisterClass("Demo", wc.hInstance);
return 0;
}