Original Post
Greetings, I have a problem that's been hounding me and I can't figure out it's source. Basically, in a simple windows application, I'm using PeekMessage() in my main program loop to handle incoming messages. The problem is that it doesn't seem to be picking up the WM_QUIT message. Here is my WndProc and my loop: If I close my program, it destroys the window but continues to run. I'm obviously doing something wrong. Any help would be appreciated!
// The WndProc function
LRESULT CALLBACK WndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
switch(nMsg)
{
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, nMsg, wParam, lParam);
}
// My program loop
BOOL bDone = FALSE;
MSG msg;
// ...unimportant code...
while(bDone == FALSE)
{
PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE);
if(msg.message == WM_QUIT)
bDone = TRUE;
else {
// ...game handling code...
}
TranslateMessage(&msgMessage);
DispatchMessage(&msgMessage);
}