在 VB6 中等待进程退出后恢复窗口 [英] Restoring a window after waiting for a process to exit in VB6

查看:31
本文介绍了在 VB6 中等待进程退出后恢复窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 win7 64 位操作系统中使用 VB6.此应用程序从 xp 迁移..

I am using VB6 in win7 64bit OS. This application is migrated from xp..

Me.WindowState = vbMinimized
WaitForProcess Shell(launchapp, vbNormalFocus)
Me.WindowState = vbNormal

在启动launchapp之前,我的代码将主应用程序最小化并启动一个exe.一旦用户关闭 exe,我的主应用程序必须从最小化状态恢复到正常状态.这在 xp 中工作正常,但在 win 7 中,我最小化的主应用程序只是闪烁并再次返回到最小化状态.

Before launching the launchapp, my code minimizes the main application and will launch an exe. Once the exe is closed by the user, my main application has to come back from minimized state to normal. This works fine in xp, but in win 7 my main app which is minimized just flashes and goes back to minimized state again.

有什么想法吗?

谢谢.

推荐答案

Windows 7 将不允许应用使用 SetForegroundWindow 获取焦点,如 文档.见备注.

Windows 7 will not allow apps to grab the focus using SetForegroundWindow, as explained in the documentation. See the remarks.

一种解决方法是暂时AttachThreadInput 到有焦点的线程,给自己焦点,然后再次分离.Karl E Peterson 提供了一个插入模块来执行此操作这里 随附 杂志文章.

One workaround is to temporarily AttachThreadInput to the thread that does have the focus, give yourself the focus, and then detach again. Karl E Peterson provides a drop-in module to do this here with accompanying magazine article.

免责声明:Windows 专家 Raymond Chen 指出,在某些情况下,此解决方法可能导致您的程序停止响应.但是,我自己从未遇到过这些错误.天啊.

Disclaimer: Windows guru Raymond Chen points out that this workaround can cause your program to stop responding in some circumstances. However I've never encountered these bugs myself. YMMV.

这篇关于在 VB6 中等待进程退出后恢复窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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