Vista中的SetForeGroundWindow错误 [英] SetForeGroundWindow Error in Vista

查看:159
本文介绍了Vista中的SetForeGroundWindow错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我们有一个旧的VB activex应用程序,它将从另一个应用程序触发.这个activex应用程序正在尝试执行setforegroundwindow,仅在VISTA中我们就遇到了错误,它在NT 2000上运行良好

  We have a old VB activex application which will be triggered from another application. This activex application is trying to do setforegroundwindow and we are getting error in VISTA alone, it is working fine NT 2000

我们尝试附加到线程并将其带到前端,但没有成功.我们尝试了showwindow,activewindow甚至Me.Show都不起作用....

  We tried attaching to thread and bring it to the front, it didnt work. We tried showwindow, activewindow and even Me.Show none of them worked....

关于此的任何想法.真的很紧急...

  any idea on this. it is really urgent...

-Mani

推荐答案

我不知道您是否已解决问题,但我遇到了这个问题,提出了一个相当不错的解决方法:

在Vista下,而不是使用不起作用的SetForegroundWindow,请执行以下操作:

SetWindowPos(WndHandle,HWND_TOPMOST,0,0,0,0 ,SWP_NOMOVE或SWP_NOSIZE);
SetWindowPos(WndHandle,HWND_NOTOPMOST,0,0,0,0,SWP_SHOWWINDOW或SWP_NOMOVE或SWP_NOSIZE);

第一个实际上抓住了焦点,但是如果您有SWP_SHOWWINDOW标记,则该窗口将显示为最高,并且您不能将其设置为非最高".但是,如果您 的标志中没有SWP_SHOWWINDOW,则第二个标志实际上将其显示为最高".

希望如此并有帮助!
I don't know if you've figured it out, but I just ran into this issue and came up with a fairly good workaround:

Under Vista, instead of using SetForegroundWindow which doesn't work, do the following:

SetWindowPos(WndHandle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE OR SWP_NOSIZE);
SetWindowPos(WndHandle,HWND_NOTOPMOST,0,0,0,0,SWP_SHOWWINDOW OR SWP_NOMOVE OR SWP_NOSIZE);

The first one actually grabs the focus but if you have SWP_SHOWWINDOW in its flags then the window is shown as topmost and you can't make it NOT Topmost.  If, however, you don't have SWP_SHOWWINDOW in its flags then the second one actually shows it while making it NOT Topmost.

Hope that makes sense and helps!


这篇关于Vista中的SetForeGroundWindow错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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