应用应该重点关注。 [英] application should take focus.

查看:62
本文介绍了应用应该重点关注。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好, 


我在一台机器上运行了2个应用程序,应用程序A和应用程序B 两个应用程序都是在Windows 7启动时启动的脚本。


应用程序A是用混合C ++和C#开发的.net


应用程序B是用C#.net窗体开发的


应用程序使用.net远程处理相互通信。有时应用程序B必须关注并且必须可见应用程序A将通知应用程序B通过远程调用获得焦点。


我尝试了setforegroundwindow和SetWindowPos以使应用程序B成为焦点但有时,它只是在任务栏上闪烁,但无法聚焦。 


任何人都可以建议解决此类问题的最佳方法是什么。或者任何其他类型的实现。


提前致谢。


解决方案

您好Vijay-K,


感谢您在此发帖。


也许您可以尝试使用进程名称来设置  ;专注于其他应用。以下是VB代码。

如果Process.GetProcessByName(" ExternalApplication")。Length> = 1则
For Each ObjProcess As Process In Process.GetProcessByName(" ExternalApplication")
AppActivate(ObjProcess.Id)
SendKeys.SendWait("〜")
Next
End If

对于C#方法,您可以看到
文件


最好的问候,


Hart




Hi All, 

i have 2 application running on a machine, application A and application B  both the applications are started when the windows 7 is started by script.

Application A is developed with mixed C++ and C#.net

Application B is developed in C#.net windows forms

both the application communicate each other using .net remoting. Sometimes application B has to take focus and must visible the application A will notify application B to take focus via remote call.

i have tried setforegroundwindow and SetWindowPos to make the application B to take focus however sometime, its just flashes on the task bar but unable to take focus. 

can any one suggest what is the best approach to be taken to solve this kind of problem. or any kind of alternative implementations.

Thanks in advance.

解决方案

Hi Vijay-K,

Thank you for posting here.

Maybe you can try to use process name to set focus on other application. The below is VB code.

If Process.GetProcessByName("ExternalApplication").Length >=1 Then
     For Each ObjProcess As Process In Process.GetProcessByName("ExternalApplication")
          AppActivate(ObjProcess.Id)
          SendKeys.SendWait("~")    
     Next
End If

For C# method you could see the document.

Best Regards,

Hart


这篇关于应用应该重点关注。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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