• ### Announcements

#### Archived

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

# Message Queue

## Recommended Posts

Does anyone know why messages sent from a loop in WinMain will ''sometimes'' not be added to the queue? I can run the program fine at home, but I take the code to a somewhat older computer and where I have a PostQuitMessage(0), that code is reached and executed, just the WM_QUIT never shows up in the queue. I''m lost... I''ve tried it on several of the university computers here and it has the same effect. Any ideas? Thanks.

I know only that which I know, but I do not know what I know.

##### Share on other sites
if(Game.GetState() != GS_UNLOADED){     Game.Unload();     PostQuitMessage(0);          // Error testing     MessageBox(hMainWindow, "Test", "Test", MB_OK);}

I have the preceding code that works. I take out the MessageBox() and it won''t quit. Anyone have any ideas?

I know only that which I know, but I do not know what I know.

##### Share on other sites
there are some messages which go directly to the window proc, bypassing the queue entirely. WM_QUIT is not one of them.

there are also some messages which get put into the queue but aren''t associated with a window. they are thread messages. WM_QUIT is one such message. but you''ll only see it if you''re telling PeekMessage and/or GetMessage not to look for messages for a specific window handle.

so, does your messae loop happen to have a PeekMessage(&msg, hWnd..., or GetMessage(&msg, hWnd... in it instead of a PeekMessage(&msg, NULL... call? if so, that''s why it''s not seeing the WM_QUIT.

if you take a look in the docs you''ll find an entire section on message queues and how they work. there''s even an example of a basic message loop in there.

##### Share on other sites
Heh, thanks. I have a fairly good understanding of the message loop, from several books... but they failed to inform me of that nice little tidbit of information. That did the trick though.

• ### Forum Statistics

• Total Topics
628281
• Total Posts
2981800

• 10
• 11
• 17
• 14
• 9