简体   繁体   English

vb.net-如何使我的主应用程序集中在桌面上?

[英]vb.net - how to keep my main app in focus on desktop?

I have an application that is created using windows forms in VB. 我有一个使用VB中的Windows窗体创建的应用程序。 In my application, I have a button that opens up another (child) form. 在我的应用程序中,我有一个打开另一个(子)窗体的按钮。 When that (child) form is closed, my other form (main app form) takes the focus, the only problem is that if I have other applications open on my desktop, when my child form closes, the main parent form goes to the back of my desktop for a second and then comes back to the top. 当该(子)窗体关闭时,我的另一个窗体(主应用程序窗体)将成为焦点,唯一的问题是,如果我在桌面上打开了其他应用程序,则当我的子窗体关闭时,主父窗体转到了后面桌面一秒钟,然后回到顶部。 So basically when you close the child form, even if the main form is on top of all of the other apps on the desktop, it will be thrown to the back momentarily and another app will be shown and then my VB app will come back to the top. 因此,基本上,当您关闭子窗体时,即使主窗体位于桌面上所有其他应用程序的顶部,该窗体也会暂时向后抛出,并显示另一个应用程序,然后我的VB应用程序将返回到顶端。 It lasts for about one second and then comes back on its own, I don't have to do anything to bring it back to the top. 它持续约一秒钟,然后自行恢复,我无需做任何事情即可将其恢复到顶部。 It is very annoying. 这很烦人。 Is there any way to prevent this? 有什么办法可以防止这种情况?

Thanks. 谢谢。

Yes. 是。 Set the topmost property of the form to true eg Form1.TopMost = True . 将表单的最高属性设置为true,例如Form1.TopMost = True In the closing function of the childforms, set this property of your main form. 在子窗体的关闭功能中,设置主窗体的此属性。 As the form closes the main form should set this property to false and then use Form/Me.Focus or Form/Me.BringToFront command if you like. 表单关闭时,主表单应将此属性设置为false,然后根据需要使用Form/Me.FocusForm/Me.BringToFront命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM