我将此代码用于主循环(我的函数):
while (running)
{
if(is_close)
{
Log().push_log("close", "message close!", logInfo);
running = active = false;
break;
}
while (PeekMessage(&msg, g_hWnd, 0, 0, PM_REMOVE))
{
std::cout << "Wnd: " << msg.message << std::endl;
if (msg.message == WM_QUIT || msg.message == WM_DESTROY || msg.message == WM_CLOSE)
{
MessageBox(0, "Hello, World", "Hello", MB_OK);
running = false;
}
// TranslateMessage(&msg);
DispatchMessage(&msg);
}
if (running && active)
render.DrawObject(g_hDC);
}
那么,我使用 WndProc:
LRESULT CALLBACK GLWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
std::cout << "Wnd Proc: " << msg << std::endl;
return DefWindowProc(hWnd, msg, wParam, lParam);
}
当我试图在我的函数中获取消息WM_QUIT
时WM_DESTROY
,WM_CLOSE
它不起作用。我的功能没有看到消息。
我怎样才能得到这个消息?