Windows message question
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?
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+
+AA_970+
Actually I have tried ignoring windows messages and it works fine. It even sped it up a bit!
-----------------------------
-cow_in_the_well
http://cowswell.gda.ods.org/
"If it's stupid but works, it's not stupid" - Murphey's Law
-----------------------------
-cow_in_the_well
http://cowswell.gda.ods.org/
"If it's stupid but works, it's not stupid" - Murphey's Law
- Thomas Cowellwebsite | journal | engine video
Really simple way of handling messages: use this function!
lntakitopi@aol.com - http://www.geocities.com/guanajam
#define READY_TO_QUIT 2int 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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement