Thread: MessageBox stops program flow

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    930

    MessageBox stops program flow

    I have two applications.
    When i send a BM_CLICK message from A to B, it opens a MessageBox on B.

    My issue is that it stops the program flow in A.
    I have to close the MessageBox on B in order to continue the program flow on A.

    Is this something normal?
    How to avoid this?
    Using Windows 10 with Code Blocks and MingW.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Yes. A MessageBox is a modal window, and the returnvalue from the function indicates what button you have pressed to close the messagebox. So this is entirely normal.

    Edit: Did not properly read the question I see, although looks like my information is somewhat related to the issue anyway, but not entirely..
    Last edited by Shakti; 06-20-2011 at 02:45 PM.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    I'm guessing you are using SendMessage()?
    Quote Originally Posted by MSDN
    SendMessage Function
    Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.

    PostMessage Function
    Places (posts) a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread to process the message.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    930
    @_Mike
    Yes i was using SendMessage().
    I never would have thought it was that easy, thanks a million, you made my day!

    @Shakti
    Thanks for your response.
    I guess you have learned something too with Mike's answer.
    Using Windows 10 with Code Blocks and MingW.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. program stops before EOF
    By doia in forum C Programming
    Replies: 2
    Last Post: 03-22-2010, 12:10 PM
  2. Program flow
    By Ducky in forum C++ Programming
    Replies: 5
    Last Post: 02-11-2010, 12:04 PM
  3. Program flow
    By Ducky in forum C++ Programming
    Replies: 4
    Last Post: 04-20-2009, 08:27 AM
  4. Program stops executing
    By bargomer in forum C++ Programming
    Replies: 16
    Last Post: 04-26-2008, 12:05 PM
  5. Program flow
    By Ducky in forum C++ Programming
    Replies: 22
    Last Post: 01-09-2008, 11:18 AM