当父级打开模式对话框时,有没有办法自动隐藏始终位于顶部的非模式对话框?

发布于 2024-08-04 05:38:26 字数 219 浏览 7 评论 0原文

我的 C# Winforms 应用程序有一个始终位于顶部的无模式查找对话框。由于用户在非模式查找对话框打开时可以访问父窗口,因此他们也可以选择打开模式对话框。由于非模式对话框始终位于顶部,因此它会遮挡模式对话框,但用户此时无法关闭非模式对话框,因为模式对话框会锁定与所有其他窗口的用户交互。

目前,我正在通过在打开任何模式窗口之前手动添加代码来关闭无模式查找对话框来解决此问题,我想知道是否有更好的解决方案?

My C# Winforms app has an always-on-top modeless find dialog. Since the user has access to the parent window while the modeless find dialog is open they can choose to open a modal dialog as well. Since the modeless dialog is always-on-top it obscures the modal dialog, but it is not possible for the user to close the modeless dialog at this point since the modal dialog locks out user interaction to all other windows.

Currently I'm working around this by manually adding code to close the modeless find dialog before opening any modal window, I'm wondering if there is a better solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你与昨日 2024-08-11 05:38:26

在调用模态对话框之前使非模态对话框不总是在最上面,然后恢复它怎么样?

modeless.TopMost = false;
// show modal dialog here
modeless.TopMost = true;

How about making the modeless dialog not-always-on-top before invoking modal dialogs, then restoring it?

modeless.TopMost = false;
// show modal dialog here
modeless.TopMost = true;
孤独难免 2024-08-11 05:38:26

查找对话框是否需要始终位于顶部?如果目的只是让它浮动在主窗体之上,那么将主窗体设置为查找对话框的父窗体是否就足够了?那么它就永远在前面,而不必总是在最上面。

否则,我会让查找对话框监听应用程序中发生的情况并采取相应的步骤。 (这可以通过多种方式解决,从事件到应用程序中所有表单的公共基础表单,再到侦听系统范围内窗口激活/停用的 CBT 挂钩。)

Does the find dialog need to be always on top? If the purpose just is to have it floating above the main form, isn't it sufficiant to set the main form as parent to the find dialog? Then it will always be in front without have to be always-on-top.

Otherwise I'd make the find dialog listen to what happens in the app and take steps accordingly. (This can be solved in numerous ways, from events to a commong base form for all forms in the app to a CBT-hook that listens system-wide for window activation/deactivation.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文