如何知道CTRL-ALT-DEL之后win32 c ++应用程序是否失去焦点? [英] How to tell if win32 c++ application lost focus after CTRL-ALT-DEL?

查看:172
本文介绍了如何知道CTRL-ALT-DEL之后win32 c ++应用程序是否失去焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 C ++ (游戏)中写了一个 win32 App ,我想知道如果应用程序已失去焦点,由于用户按<大骨节病> CTRL - <大骨节病> ALT - <大骨节病> DEL 并启动任务管理器。我怎样才能做到这一点?检测事件后我想要做的事情就是尽量减少我的游戏窗口并暂停处理(动画,音频等)。但是,如果用户从 CTRL - ALT - DEL 菜单返回到游戏,那么它应该照常运行。我以为我可以检查 CTRL ALT DEL 上的按键,但这似乎不起作用,只是作出反应在失去焦点 WM_KILLFOCUS )是不是我想要的。

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. 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. 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.

推荐答案

可以使用 WTSRegisterSessionNotification(),你会当用户按Ctrl + Alt + Del键,并切换到安全桌面得到WM_WTSSESSION_CHANGE消息。

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.

当心你不能说它实际上是他切换到的安全桌面,这将是相当讨厌的安全漏洞。当他切换到另一个登录会话时,您也会收到通知。当然,你也可以停止你的游戏。

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.

对于这个问题,游戏应该在游戏窗口失去前景的时候自动暂停。没有人喜欢被杀害时,他们切换到他们的电子邮件阅读:)使用的 WM_ACTIVATEAPP消息

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

这篇关于如何知道CTRL-ALT-DEL之后win32 c ++应用程序是否失去焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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