[英]How to tell if win32 c++ application lost focus after CTRL-ALT-DEL?
I've written a win32 App
in C++
(a game) and I want to be able to know if the application has lost focus due to the user pressing CTRL - ALT - DEL and starting the task manager
. 我已经用
C++
(一个游戏)编写了一个win32 App
,我想知道该应用程序是否由于用户按下CTRL - ALT - DEL并启动task manager
而失去了焦点。 How can I do this? 我怎样才能做到这一点? What I want to do after detecting the event is to minimize the window of my game and pause its processing (animations, audio, etc.).
在检测到事件后,我想做的是最小化游戏窗口并暂停其处理(动画,音频等)。 However, if the user returns from the CTRL - ALT - DEL menu to the game then it should keep running as usual.
但是,如果用户从CTRL - ALT - DEL菜单返回到游戏,则它应继续照常运行。 I've thought that I could check for key presses on CTRL , ALT and DEL but that doesn't seem to work and just reacting to the
lost the focus
( WM_KILLFOCUS
) is not what I want. 我以为可以检查CTRL , ALT和DEL上的按键,但这似乎不起作用,只是对
lost the focus
( WM_KILLFOCUS
)做出反应不是我想要的。
You can use WTSRegisterSessionNotification() , you'll get the WM_WTSSESSION_CHANGE message when the user presses Ctrl+Alt+Del and switches to the secure desktop. 您可以使用WTSRegisterSessionNotification() ,当用户按下Ctrl + Alt + Del并切换到安全桌面时,将收到WM_WTSSESSION_CHANGE消息。
Beware that you cannot tell that it was actually the secure desktop that he switched to, that would be rather nasty security leak. 请注意,您不能说出它实际上是他切换到的安全桌面,那将是非常讨厌的安全漏洞。 You'll also get the notification when he switches to another logon session.
当他切换到另一个登录会话时,您还将收到通知。 Also a case where you want to stop your game of course.
当然,这也是您要停止游戏的情况。
For that matter, a game ought to automatically pause whenever the game window loses the foreground. 因此,只要游戏窗口失去前景,游戏就应该自动暂停。 Nobody likes to be killed when they switch to their email reader :) Use the WM_ACTIVATEAPP message
当他们切换到电子邮件阅读器时,没人喜欢被杀死:)使用WM_ACTIVATEAPP消息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.