Windows窗体没有得到关注 [英] Windows form not getting focus

查看:89
本文介绍了Windows窗体没有得到关注的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在我的应用程序中,我必须在加载主应用程序窗口之前显示一个'登录窗口'。它正确加载,但问题是 
无法获得焦点。


我尝试过  TopMost = true,form.Focus(),form.Show(),form.Select(),form.Activate() 以及一些pinvoke方法,例如  SetActiveWindow(handle),
SetForegroundWindow(handle),SetFocus(handle)
(以及他们的不同组合......)。但是没有解决我的问题。

I have tried TopMost = true, form.Focus(), form.Show(), form.Select(), form.Activate() and also some pinvoke methods such as SetActiveWindow(handle), SetForegroundWindow(handle), SetFocus(handle)(and their different combinations too..). But not solved my problem.


但是,我的登录窗口首先显示在应用程序列表上(当我们点击Alt + Tab时显示)并且焦点是获得应用程序,这是第二位。

But, my Login window is showing in first place on Application List(displaying when we hit Alt+Tab) and the focus is getting on the application, which is in second place.


任何人请帮忙......这是一个高优先级问题......

Anyone please help... Its a high priority issue...


先谢谢..

Thanks in advance..

推荐答案

可能是你不小心设置它的情况在应用程序的某个地方,所以重点放在了表单,然后快速返回到应用程序。将登录表单中的调试点添加到方法/事件中以进行聚焦,并检查是否存在
,以及它是否在下一步。
Hi, It may be the case where you are accidentally setting it somewhere in application so the focus goes to the form and then quickly goes back to the application. Add a debug point in the login form to the method/event for focus and check if it comes there at all and if it does where it does next.


这篇关于Windows窗体没有得到关注的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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