locked
Message Boxes with no owner window RRS feed

  • Question

  • Can someone explain to me why this happens? If I run the following code in WM6 with any other full screen app already running:

    #include <windows.h>
    
    int wmain(int argc, _TCHAR* argv[])
    {
     MessageBox(NULL, L"Box1", L"Box1", MB_OK);
     MessageBox(NULL, L"Box2", L"Box2", MB_OK);
     return 0;
    }

    The first message box will appear on top of any open windows, but the second message box will be hidden behind all other windows.  Why is the first box in the foreground and the second box in the background?

     

    Thanks in advance

    Tuesday, May 4, 2010 9:59 PM

Answers

  • instead of MB_OK I usually use MB_OK | MB_SETFOREGROUND | MB_TOPMOST when showing message boxes.
    • Marked as answer by warrentang Monday, May 10, 2010 3:51 AM
    Wednesday, May 5, 2010 2:54 PM

All replies

  • instead of MB_OK I usually use MB_OK | MB_SETFOREGROUND | MB_TOPMOST when showing message boxes.
    • Marked as answer by warrentang Monday, May 10, 2010 3:51 AM
    Wednesday, May 5, 2010 2:54 PM
  • I realize that I can force the message boxes to the front by setting the flags; my question is, why is the first box in front and the second box hidden behind everything when I don't set those flags?  Why can't I expect similar behavior from both boxes?
    Wednesday, May 5, 2010 6:25 PM