messagebox on top of splashscreen

c#

Solution

Try this it will show your MessageBox at the top of every window currently open.

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

This will keep the message box on top of every window because we are passing `MB_TOPMOST` Value to MessageBoxOptions parameter. You can visit this for more information.

Problem

I have a messagebox that pops-up when a user can't be loaded (in this case because he don't have a warehouse) while loading there is a splashscreen that shows that the data is being loaded. I tried the TopMost set to true, but yeah the spalshscreen isn't the parent so it don't work, so i tried TopLevel set to true but it didn't do the trick. So i tried: ``` MessageBox.Show(Splashscreen.LoadingScreen.ActiveForm, e.Message, "No warehouses", MessageBoxButtons.OK, MessageBoxIcon.Error); ``` but this is cross thread so I get an: InvalidOperationException So is there another way to set the messagebox on top?

Original source