Jump to content
  • Advertisement

Archived

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

_Josh

Windows message question

This topic is 6547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!