加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

Windows中的活动窗口和QWidget :: activateWindow()

发布时间:2020-12-14 04:27:46 所属栏目:Windows 来源:网络整理
导读:QWidget :: activateWindow()的Qt文档说明: On Windows,if you are calling this when the application is not currently the active one then it will not make it the active window. It will change the color of the taskbar entry to indicate that th
QWidget :: activateWindow()的Qt文档说明:

On Windows,if you are calling this
when the application is not currently
the active one then it will not make
it the active window. It will change
the color of the taskbar entry to
indicate that the window has changed
in some way. This is because Microsoft
does not allow an application to
interrupt what the user is currently
doing in another application.

但是,Skype似乎无视这一规则.如果Skype正在运行但不是活动应用程序,我可以从开始菜单启动它,它将现有实例带到前台,激活它并获取输入焦点.

我怎么能这样做?

解决方法

(注意:这特定于QtSingleApplication的工作原理)

对于我的问题,解决方案非常简单.只需调用AllowSetForegroundWindow(ASF_ANY);在应用程序的开头,因此允许原始进程通过使用SetForegroundWindow()将自己带到前台.没有奇怪的黑客,只需添加一行代码,也无需修改QtSingleApplication.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读