-
June 19th, 2008, 01:43 PM
#1
MessageBox and relationship with parent's message map
I ran into an odd situation. I posted hundreds of custom messages to my main window, and when handling these messages the rare situation can occur where I pop up an error dialog. At any rate, during a test this error occurred quite often and my screen was filled with message boxes. Being modal, I was surprised by this since the parent's execution is stopped at that call to MessageBox (or "DoModal()") until the message box is closed. I expected an unending series of error dialogs but not simultaneous ones.
Then it occurred to me that when a message box is displayed the parent must still be handling certain messages, if this wasn't the case then it wouldn't be able to repaint itself if the message box was moved. But the parent's message map thread has effectively been halted.
So what happens? Does the modal dialog force explicitly instruct its parent to handle certain messages while it's active?
I did a few searches and couldn't find the answer to this online.
Why are the "tolerant" so easy to offend?
-
June 19th, 2008, 07:18 PM
#2
Re: MessageBox and relationship with parent's message map
modal dialog doesn't explicity instruct the parent to do anything. If you keep Translating and Dispatching messages to whatever window in your implementation of DoModal, that will take care of what needs to be done.
-
June 19th, 2008, 11:41 PM
#3
Re: MessageBox and relationship with parent's message map
Originally Posted by kirants
modal dialog doesn't explicity instruct the parent to do anything. If you keep Translating and Dispatching messages to whatever window in your implementation of DoModal, that will take care of what needs to be done.
I'm just calling the standard MessageBox function. Somehow the main message map must continue to process message map functions otherwise a mainframe wouldn't be able to repaint itself while a message box is activated. There's got to be something within DoModal (maybe something that's even hidden deep in Microsoft's API) that at least causes the message map within the main thread to continue pumping certain messages.
Why are the "tolerant" so easy to offend?
-
June 20th, 2008, 12:14 AM
#4
Re: MessageBox and relationship with parent's message map
DoModal implements a simple message loop ( GetMessage, TranslateMessage, DispatchMessage ). It does this for all windows, so , if there are messages generated for the parent window, they get dispatched to them and get processed by the parent window procedure. It is just that , messages like mouse messages aren't even generated for the parent window because it is disabled.
-
June 20th, 2008, 05:45 PM
#5
Re: MessageBox and relationship with parent's message map
Ah! That explains why my custom messages somehow get handled while that little message is open.
Thanks
Why are the "tolerant" so easy to offend?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|