麻烦与VB6应用程序,带来一个对话框的前面,专注于Windows 7 [英] Trouble with VB6 app, bringing a dialog to front and focus on Windows 7

查看:168
本文介绍了麻烦与VB6应用程序,带来一个对话框的前面,专注于Windows 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的实用程序应用程序写在Visual Basic 6,已经在XP客户端上愉快地运行多年,直到最近一个使用Windows 7的客户端已通知并告诉我,行为是不同的。

I have a small utility app written in Visual Basic 6 that has been happily running on XP clients for many years until recently a client who is using Windows 7 has notified and shown me that the behaviour is different.

当我的VB应用程序显示对话框时,它保持隐藏,直到用户在任务栏中点击它。

When my VB app displays the dialog, it remains hidden until the user clicks on it in the taskbar.

我更改了代码,而不是使用.show vbModal命令,我更改为以非模态方式显示表单,然后添加了各种API调用,如BringWindowToFront和SetWindowPos使它最顶部和调用.focus的形式,尽管这些额外的指令,我可以实现的最好的结果是使表单闪烁提示用户点击它。

I changed the code so rather than using a ".show vbModal" command, I changed to displaying the form with non-modally, and then added various API calls like BringWindowToFront and SetWindowPos to make it top most AND calling .focus on the form, despite these extra instructions the best result I can achieve is to make the form flash prompting the user to click on it.

无论我尝试过什么,我都无法让窗口显示在最上方,而且焦点没有用户干预。

No matter what I've tried I cannot make the window display topmost, and with focus, without user intervention.

请注意。这是一个ActiveX的exe项目,并正在通过COM通过Win16应用程序调用。

Note. this is an ActiveX exe project and is being called by a Win16 app through COM.

有没有人遇到这种行为,知道一个解决方案?

Has anyone else encountered this behaviour and know of a solution?

任何建议/建议赞赏,谢谢。

Any suggestions/advice appreciated, thanks.

推荐答案

应用程序不能Windows)偷焦点。调用应用程序应该真的调用 AllowSetForegroundWindow() (如果它在win16上可用)允许COM进程窃取焦点,或调用 SetForegroundWindow() 本身。

Applications can't (without lying to Windows) steal focus. The calling app should really call AllowSetForegroundWindow() (if it's available on win16) to allow the COM process to steal the focus, or call SetForegroundWindow() itself.

有关设置焦点的条件,请参阅 SetForegroundWindow()的帮助。

See the help for SetForegroundWindow() for the conditions on setting focus.

这篇关于麻烦与VB6应用程序,带来一个对话框的前面,专注于Windows 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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