none
MessageBox.Show goes to Z-order bottom RRS feed

  • Question

  • Have a C# Windows Forms application, with a multitude of MessageBox.Show invocations. On inexplicable occasions, the message box goes to Z-order bottom, so the user doesn't see it, and only looking at the task bar exposes the popup.

    Have made use of MessageBoxOptions.DefaultDesktopOnly to ensure the popup gets seen, but now on inexplicable occasions the main form goes to Z-order bottom. So after executing the MessageBox.Show with MessageBoxOptions.DefaultDesktopOnly, the user sees the MessageBox popup, but under that is perhaps Windows Explorer, and under that is the original C# Windows Forms application. It's as if the MessageBoxOptions.DefaultDesktopOnly is pulling the popup to the top Z-order and pushing the main form to the bottom Z-order. I understand that MessageBoxOptions.DefaultDesktopOnly causes the form to lose focus, but to be pushed to bottom Z-order?

    All I want is to ensure the MessageBox.Show popup is seen. How to do that?


    Sunday, April 15, 2018 12:00 AM

Answers

  • have you tried

    MessageBox.Show(this,"Some message");

    .

    MessageBox.Show(this,
        "You have not inputted a username or password. Would you like to configure your settings now?",
        "Settings Needed",
        MessageBoxButtons.YesNo,
        MessageBoxIcon.Question,
        MessageBoxDefaultButton.Button1,  // specify "Yes" as the default
        (MessageBoxOptions)0x40000);      // specify MB_TOPMOST            


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by Frank Badami Wednesday, April 18, 2018 10:24 PM
    Sunday, April 15, 2018 12:19 AM
    Moderator

All replies

  • have you tried

    MessageBox.Show(this,"Some message");

    .

    MessageBox.Show(this,
        "You have not inputted a username or password. Would you like to configure your settings now?",
        "Settings Needed",
        MessageBoxButtons.YesNo,
        MessageBoxIcon.Question,
        MessageBoxDefaultButton.Button1,  // specify "Yes" as the default
        (MessageBoxOptions)0x40000);      // specify MB_TOPMOST            


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by Frank Badami Wednesday, April 18, 2018 10:24 PM
    Sunday, April 15, 2018 12:19 AM
    Moderator
  • I have not. I've seen suggestions to use "this" as the first MessageBox.Show argument, but I cannot find any Microsoft reference that shows anything but a string first argument. Will try, thanks.
    Sunday, April 15, 2018 12:27 AM
  • Hello,

     When you use static method MessageBox the calling app is suspended

    until the MessageBox is closed.  App Focus and MessageBox regarding

    Z order is arbitrary.  Meaning, any window including the app can gain

    focus but will not be displayed as TopMost. MessageBox take precedence

    until closed even if lost Focus.

     

     Hope this helps :)

    Sunday, April 15, 2018 12:50 AM