如何制作一个非模态最顶层对话框,该对话框仅相对于 WinForms 中的父窗体位于最顶层?
考虑关于“关于”对话框的这一点,但我确信它适用于其他地方(例如查找框)
抱歉,如果这是一个骗局,但我找不到这个或如何阐明它的最后一部分仅在顶部父母的。 如何制作一个始终位于父表单之上、但非模态、但不覆盖其他应用程序的表单?
Thinking about this for an About dialog but I'm sure it's applicable in other places (say a find box)
Sorry if this is a dupe, but I couldn't find this or how to articulate the last part about it only being on top of the parent. How do you make a form that is always on top of the parent form, but is non-modal, but doesn't cover up other apps?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试以下方法打开对话框:
关键是指定对话框的所有者。
Try this to open your dialog:
The key is to assign dialog's owner.
不确定你的意思; Form.ShowDialog 仅相对于父级而言是模态的,而不是应用程序,除非应用程序是单线程的。
例如,我制作了一个应用程序来测试它,其组织如下:
mainform:
2个按钮,每个按钮都会启动一个线程,该线程创建frmDialog1并调用ShowDialog
frmDialog1:
创建 frmDialog2 并在其上调用 ShowDialog 的单个按钮。
frmDialog2:
什么都不做(即空白),
当它们全部运行时,我 我可以访问/拖动主窗体。 仅当我没有单击显示对话框 2 的按钮时,我也可以对 frmDialog1(两个版本)执行相同的操作。
Not sure exactly what you mean; Form.ShowDialog is only modal with respect to the parent, not the application, unless the application is single threaded.
For example, I made an app to test this which was organized like the following:
mainform:
2 buttons, each of which begins a thread that creates a frmDialog1 and calls ShowDialog
frmDialog1:
single button which creates a frmDialog2 and calls ShowDialog on it.
frmDialog2:
does nothing (ie. blank)
when they were all running I could access/drag mainform. I could also do the same with frmDialog1 (both versions) only if I hadn't clicked the button that shows dialog 2.