如何将wpf MessageBox.Owner设置为桌面窗口,因为SplashScreen关闭了MessageBox [英] how to set wpf MessageBox.Owner to desktop window because SplashScreen closes MessageBox

查看:353
本文介绍了如何将wpf MessageBox.Owner设置为桌面窗口,因为SplashScreen关闭了MessageBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在WPF中使用 SplashScreen 功能,方法是将位图的 Build Action 设置为Splashscreen.在初始屏幕的后面,正在检查许可信息,如果失败,则显示 MessageBox .

根据此反馈 ,这是因为MessageBox.Owner是初始屏幕,并且即使另一个窗口是MessageBox,一旦打开另一个窗口,初始屏幕窗口也会关闭,这又关闭了MessageBox,因此用户永远不会看到MessageBox.

因此,解决方法是将MessageBox.Owner设置为另一个窗口,但这意味着我必须实例化可能甚至不需要的另一个窗口.

是否可以将MessageBox.Owner设置为桌面窗口?以及方法,因为想到的唯一其他函数是 GetDesktopWindow() api函数,但是该函数返回窗口句柄和MessageBox.Owner是WPF窗口.

解决方案

我发现了问题.我还使用了导致以下情况的内置启动屏幕:Feedback, it is because the MessageBox.Owner is the splash screen and as soon as another window is open even if it is a MessageBox the splash screen window is closed which then in turn closes the MessageBox, so the user never sees the MessageBox.

So the workaround would be to set the MessageBox.Owner to another window, but that would mean that I have to instantiate another window which might not even be needed.

Would it be possible to set the MessageBox.Owner to the desktop window? And how, because the only other function that comes to mind is the GetDesktopWindow() api function, but that returns a window handle and MessageBox.Owner is a WPF Window.

解决方案

I found the problem. I am also using the build-in splash screen which causes this: WPF SplashScreen closes MessageBox

这篇关于如何将wpf MessageBox.Owner设置为桌面窗口,因为SplashScreen关闭了MessageBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆