Window Message Handling

Started by
1 comment, last by Prozak 20 years, 6 months ago
Its n00b question time (I should know this btw, shame on me): Ok, I create 5 windows. How do I create the following loop to handle all their messages?

/**///->[-Message Loop-]	

while(WndNotClosed)
{
   WaitMessage();
   GetMessage(msg, NULL,0,0);
   TranslateMessage(msg);
   DispatchMessage(msg);	
};	
Do I have to look into "msg.hwnd", and that gives me a pointer to one of my 5 windows? (im betting that is the answer) Thanx,

[Hugo Ferreira][Positronic Dreams]
All your code are belong to us!

Advertisement
The second parameter to GetMessage (you supplied NULL) takes the handle of the windows whose messages you want to get.

Supplying NULL will get the message of any window in your thread. Thus the loop you showed us will already handle their messages.

BTW, you don''t need to have WaitMessage in front of GetMessage, since GetMessage will also suspend the current thread if no messages in the queue.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Please read the winprog.org tutorials if you''re not 100% certain how to set up your message loop. Getting it wrong leads to REALLY REALLY HARD to track down errors.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis

This topic is closed to new replies.

Advertisement