简体   繁体   中英

messagebox on top of splashscreen

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?

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.

I faced similar issue - my MessageBox get hide behind of SplashScreen. Neither use of "this" adwiced here, nor "new Form" works for my WPF application. However, the construction

MessageBox.Show(msg, errType, MessageBoxButton.OK, 
    MessageBoxImage.Asterisk, reply, MessageBoxOptions.ServiceNotification);

with MessageBoxOptions.ServiceNotification helps, putting MessageBox on top of SplashScreen.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM