当父级打开模式对话框时,是否可以自动隐藏始终位于顶部的无模式对话框? [英] Is there a way to auto-hide a always-on-top modeless dialog when the parent opens a modal dialog?

查看:95
本文介绍了当父级打开模式对话框时,是否可以自动隐藏始终位于顶部的无模式对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的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?

推荐答案

查找对话框是否必须始终位于顶部?如果仅是为了使它浮动在主窗体上方,将主窗体设置为查找对话框的父级就足够了吗?然后它将始终位于最前面,而不必始终位于最上层.

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.

否则,我将使查找"对话框侦听应用程序中发生的情况,并采取相应的措施. (这可以通过多种方式解决,从事件到应用程序中所有表单的通用基本表单,再到在系统范围内侦听窗口激活/停用的CBT钩子.)

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.)

这篇关于当父级打开模式对话框时,是否可以自动隐藏始终位于顶部的无模式对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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