diff --git a/main.cpp b/main.cpp index 6db108b..7749d6e 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,19 @@ #include +/** +*消息处理函数 +*/ +LRESULT CALLBACK GLWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_CLOSE: + PostQuitMessage(0); + return 0; + } + return DefWindowProc(hwnd, msg, wParam, lParam); +} + INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { /*注册窗口*/ @@ -12,7 +26,7 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine wndclass.hIcon = NULL; wndclass.hIconSm = NULL; wndclass.hInstance = hInstance; - wndclass.lpfnWndProc = NULL; + wndclass.lpfnWndProc = GLWindowProc; wndclass.lpszClassName = L"GLWindow"; wndclass.lpszMenuName = NULL; wndclass.style = CS_VREDRAW | CS_HREDRAW;