Delphi - Win7窗口焦点问题 [英] Delphi - Win7 Window Focus Issue

查看:147
本文介绍了Delphi - Win7窗口焦点问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过CreateProcess()来执行exe文件,并通过SetForegroundWindow()来设置前台进程。
,但它不能在Win7中工作,所以我必须点击任务栏中的图标。

如何实现我想要的行为(即启动BringToForeground)?

解决方案

您甚至不应该尝试这样做。 SetForegroundWindow 中的更改是有意的 - 它可以防止从用户想要关注的焦点的应用程序。请参阅上面的链接的注释部分。

Win7可能不会让非管理员用户更改所需的注册表设置,更不用说重新启动系统。



您应该只使用

I execute exe file by CreateProcess() and set foreground process by SetForegroundWindow(). but it doesn't work in Win7 so I have to click icon in taskbar.

How can I implement the behaviour I want (which is to Launch and BringToForeground)?

解决方案

You shouldn't even try to do this. The change in SetForegroundWindow was intentional - it prevents applications from stealing the focus from what the user wants to have focus. See the Remarks section of the link above.

Win7 probably won't let non-administrative users change the needed registry setting, much less do it without a restart of the system.

You should just use FlashWindow instead to get the user's attention, as Microsoft recommends. Any application that insists on stealing focus away from what I choose to do will be uninstalled immediately.

这篇关于Delphi - Win7窗口焦点问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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