Qt 需要将 Qt 应用程序带到从 win32 应用程序调用的前台 [英] Qt Need to bring Qt application to foreground called from win32 application

查看:46
本文介绍了Qt 需要将 Qt 应用程序带到从 win32 应用程序调用的前台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的 win32 应用程序,它使用 createProcess 方法调用 Qt 应用程序.

I have a simple win32 application that uses the createProcess method to call Qt application.

问题是我喜欢将 Qt 应用程序置于前台.

The problem is that I like to bring the Qt application to the foreground.

谁来负责?父 win32 应用程序还是 Qt 应用程序?

Who is responsible for this? The parent win32 app or the Qt application?

推荐答案

当前具有前台焦点的应用程序是唯一允许改变前台焦点的应用程序重点.您需要使用 SetForegroundWindow 函数行使这项权利.

The application that currently has the foreground focus is the only one that is allowed to change the foreground focus. You need to use the SetForegroundWindow function to exercise this right.

备注"文档中的部分包含适用的限制列表:

The "Remarks" section in the documentation contains an applicable list of restrictions:

系统限制了哪些进程可以设置前台窗口.只有满足以下条件之一,进程才能设置前台窗口:

The system restricts which processes can set the foreground window. A process can set the foreground window only if one of the following conditions is true:

  • 进程是前台进程.
  • 该进程由前台进程启动.
  • 进程收到最后一个输入事件.
  • 没有前台进程.
  • 正在调试前台进程.
  • 前台未锁定(请参阅LockSetForegroundWindow).
  • 前台锁超时已过期(请参阅SystemParametersInfo 中的SPI_GETFOREGROUNDLOCKTIMEOUT).
  • 没有菜单处于活动状态.

当用户正在使用另一个窗口时,应用程序不能强制一个窗口到前台.相反,Windows 会闪烁窗口的任务栏按钮以通知用户.

An application cannot force a window to the foreground while the user is working with another window. Instead, Windows flashes the taskbar button of the window to notify the user.

真正的问题是你为什么需要这样做.更改前台应用程序很可能会给您带来麻烦,无论是 Windows 对其施加的所有限制,还是您的用户.这是一种非常敌视用户的行为,这也是 Windows 近年来收紧对其限制的原因之一.

The real question is why you need to do this at all. Changing the foreground application is very likely to get you into trouble, either with all of the restrictions that Windows places on it, or with your users. It's a very user-hostile action, which is one of the reasons why Windows has tightened up the restrictions on it in recent years.

这篇关于Qt 需要将 Qt 应用程序带到从 win32 应用程序调用的前台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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