防止表单窃取焦点 [英] Prevent form from stealing focus

查看:35
本文介绍了防止表单窃取焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行我的 VB.NET Winforms 应用程序时,我不希望它从其他打开的应用程序中窃取焦点.仅供参考,我的应用程序是从命令行启动的,但这应该没什么区别.我看过问题 577076 但这似乎不起作用.

When I run my VB.NET Winforms app I do not want it to steal the focus from the other open apps. FYI, my app is started from the command line but that shouldn't make a difference. I've seen question 577076 but that doesn't seem to work.

最好的方法是什么?

推荐答案

以下是我为实现此目的所做的工作:

Here is what I did to get this working:

我将以下代码添加到我的 Form1.vb 文件中:

I added the following code to my Form1.vb file:

Protected Overloads Overrides ReadOnly Property ShowWithoutActivation() As Boolean  
    Get  
        Return True  
    End Get  
End Property

但是还是没有成功.

然后我取消选中项目属性的应用程序"选项卡上的启用应用程序框架"复选框.

Then I unchecked the Enable Application Framework checkbox on the Application tab of the project properties.

成功!!!

这篇关于防止表单窃取焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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