Archived

This topic is now archived and is closed to further replies.

_Josh

Windows message question

Recommended Posts

_Josh    122
If I were to go out of my main game loop for a long time, and wasn''t checking for windows messages, what would happen? Could it crash the computer?

Share this post


Link to post
Share on other sites
+AA_970+    122
Your game would crash, which may or may not crash windows. If that dosen''t happen your game will probably be dead window where it''s just a window and noting can''t be done on it.


+AA_970+

Share this post


Link to post
Share on other sites
SHilbert    652
Really simple way of handling messages: use this function!
    #define READY_TO_QUIT 2

int Handle_Messages()
{
// Get the message

MSG msg;

// Handle all waiting messages until none are left.

if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
// If the message was for quitting, quit!
if (!GetMessage(&msg, NULL, 0, 0))
return READY_TO_QUIT;

// Otherwise, do what would normally be done for it.
TranslateMessage(&msg);
DispatchMessage(&msg);

if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
return Handle_Messages();
}
if(!app_active)
{
// Wait for a message

WaitMessage();

// Handle it

return Handle_Messages();
}

return 1;
}
You can just call that every loop, or every so often during loading code. Just check if it returned READY_TO_QUIT so you can quit when Windows wants you to!

lntakitopi@aol.com - http://www.geocities.com/guanajam

Share this post


Link to post
Share on other sites