gpt4 book ai didi

c++ - Qt 需要将 Qt 应用程序带到前台,从 win32 应用程序调用

转载 作者:太空狗 更新时间:2023-10-29 20:47:21 24 4
gpt4 key购买 nike

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

问题是我喜欢把Qt应用带到前台。

谁对此负责?父 win32 应用程序或 Qt 应用程序?

最佳答案

当前拥有前景焦点的应用程序是唯一被允许更改前景焦点的应用程序。您需要使用 SetForegroundWindow function行使此权利。

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

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:

  • The process is the foreground process.
  • The process was started by the foreground process.
  • The process received the last input event.
  • There is no foreground process.
  • The foreground process is being debugged.
  • The foreground is not locked (see LockSetForegroundWindow).
  • The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).
  • No menus are active.

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 对其限制收紧的原因之一。

关于c++ - Qt 需要将 Qt 应用程序带到前台,从 win32 应用程序调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5919928/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com