CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 1999
    Posts
    492

    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?

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    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.

  3. #3
    Join Date
    Aug 1999
    Posts
    492

    Re: MessageBox and relationship with parent's message map

    Quote 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?

  4. #4
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    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.

  5. #5
    Join Date
    Aug 1999
    Posts
    492

    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
  •  





Click Here to Expand Forum to Full Width

Featured