Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

(c++ win32) Possible to get the window msgs via message loop?

This topic is 4342 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

Is it possible to read the window messages via the message loop? eg:
MSG msg = {0};

while(msg.message != WM_QUIT) {
	if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {			
		TranslateMessage(&msg);
		DispatchMessage(&msg);

		//doesn't work
		if(msg.message == WM_SIZE) {
			Beep(111,111);
		}
	}
}


thanks [Edited by - johnnyBravo on July 5, 2006 7:35:42 PM]

Share this post


Link to post
Share on other sites
Advertisement
Sure it's possible, but in general it's not the best way to do things - you should handle messages in each window's WndProc instead, unless you need a global thread-wide trap on certain messages for some reason.

Share this post


Link to post
Share on other sites
the WM_SIZE one doesn't work because WM_SIZE is sent, not posted. for example, CreateWindow sends the WM_GETMINMAXINFO, WM_SIZE, WM_NCCREATE, WM_CREATE messages directly to the window procedure, bypassing the windows message queue and access via the message loop. that is why your trapping of WM_SIZE doesn't work. WM_SIZE is always sent by the system. hooking, however, might be able to trap sent messages... don't quote me on that just yet though because i can't recall off the top of my head (though it should because Spy++ uses hooking and can tell if a message was sent or posted). to see which messages are commonly sent or posted, check out Spy++, each message will have an S or a P next to it indicating whether or not the message was sent or posted.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!