Can't get window to close!
I''m getting the code from TOWGPG!
I have this:
void Game_Main()
{
//all game processing goes here
//if escape is pressed close the window
if (KEYDOWN(VK_ESCAPE))
SendMessage(main_window_handle, WM_CLOSE, 0, 0);
} // end game main
I''ve tried a message box in there so I know it gets through the is statement!
I have this in the winproc:
case WM_DESTROY:
{
//kill the application, this sends a WM_QUIT message
PostQuitMessage(0);
//return success
return(0);
and this in winmain:
while(TRUE)
{
//tests for a message in the queue, gets it if there is
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
//tests if it''s a quit
if (msg.message == WM_QUIT)
{
MessageBox(NULL, "hello", "hello", MB_OK);
break;
}
//translate any accelerator keys
TranslateMessage(&msg);
//send the message to the window procedure
DispatchMessage(&msg);
}//end if
//enter main game function
Game_Main();
}//end while loop
I''ve checked the source code from the CD and can''t find any mistakes with it. Any Ideas?
OK, I changed the:
if (KEYDOWN(VK_ESCAPE))
SendMessage(main_window_handle, WM_CLOSE, 0, 0);
to:
if (KEYDOWN(VK_ESCAPE))
PostQuitMessage(0);
and it works fine. Is there anyting wrong with doing it this way?
if (KEYDOWN(VK_ESCAPE))
SendMessage(main_window_handle, WM_CLOSE, 0, 0);
to:
if (KEYDOWN(VK_ESCAPE))
PostQuitMessage(0);
and it works fine. Is there anyting wrong with doing it this way?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement