Alex
Alex

Reputation: 910

MessageBox on the top from all threads

When the application starts, splash screen is shown from another thread. But, in case an error during start up - message box will be shown. The problem is: messagebox is shown under the splash. I have used IWin32Window owner property, even tried to use MessageBoxOptions.DefaultDesktopOnly property, but id did not help.

How can I manage this situation ?

PS: Tried to create invisible window, set TopMost - and show MessageBox. Did not work.

Upvotes: 0

Views: 1102

Answers (1)

Syed Farjad Zia Zaidi
Syed Farjad Zia Zaidi

Reputation: 3360

I created a similar situation using multi-threading and used this code to keep the MessageBox on top of the window. Basically this code makes the message box top most.

MessageBox.Show(this,
    "Your text",
    "Settings Needed",
    MessageBoxButtons.YesNo,
    MessageBoxIcon.Question,
    MessageBoxDefaultButton.Button1,
    (MessageBoxOptions)0x40000); // this is MB_TOPMOST flag

Upvotes: 2

Related Questions