子表单在第一次单击父表单时失去焦点。如何解决这个问题?

发布于 2024-09-24 01:54:06 字数 363 浏览 1 评论 0原文

我正在编写一个新的基于插件的应用程序。这会在其自己的应用程序域中加载程序集,并通过 Application.Run(pluginForm) 在每个程序集中显示指定的主表单。在应用程序域内调用 Application.Run(pluginForm) 之前,我将加载器应用程序中的主窗体设置为每个pluginForm 的父窗体。因此,当pluginForm显示时,它总是显示在加载器应用程序的mainForm前面。

我的问题是,当用户第一次单击pluginForm(子表单)时,它会失去焦点,而mainForm(加载应用程序的表单)会获得焦点。 (但是pluginForm保留在前面)因此用户最终必须单击两次才能使pluginForm第一次获得焦点。

这很烦人。我该如何解决这个问题?

Im writing a new plugin based app. This loads assemblies in their own app domains and displays the specified main forms within each via Application.Run(pluginForm). I set the main form in the loader app as the parent of each pluginForm before calling Application.Run(pluginForm) inside the app domain. Hence when the pluginForm shows it always gets displayed in front of the mainForm of the loader app.

My problem is when a user clicks for the first time on the pluginForm (child form), it looses focus and the mainForm (loader app's form) gets focus. (However the pluginForm stays in front) Hence the user ends up having to click twice to get the pluginForm to focus for the first time.

This is pretty annoying. How can I fix this?

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

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

发布评论

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

评论(2

等待圉鍢 2024-10-01 01:54:06

您应该通过调用 ShowDialog() 在父级 UI 线程上将子窗体显示为模式对话框。

You should show the child forms as modal dialogs on the parent's UI thread by calling ShowDialog().

旧时模样 2024-10-01 01:54:06

当您调用子表单时,请使用

childForm.ShowDialog(parentForm);

OR 等效项

childForm.ShowDialog(this);

When you call the child Forms use

childForm.ShowDialog(parentForm);

OR the equivalent

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