简体   繁体   English

如何判断CTRL-ALT-DEL之后Win32 C ++应用程序是否失去焦点?

[英]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. 我以为可以检查CTRLALTDEL上的按键,但这似乎不起作用,只是对lost the focusWM_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.

相关问题 在 C++ Win32 应用程序中,无论焦点如何,如何检测 ALT 键按下 - How to detect ALT key press regardless focus in C++ Win32 application TeamViewer如何以编程方式在Windows上模拟Ctrl-Alt-Del? - How TeamViewer simulates Ctrl-Alt-Del on Windows programmatically? 通过 Gina 修改 Windows ctrl-alt-del 行为 - Modifying Windows ctrl-alt-del behavior through Gina 调试 Win32 应用程序 c++ - Debugging a Win32 application c++ 如何检测用户是否按了Ctrl-Alt-Del或Alt-Tab,以便可以最小化程序? - How to detect if a user pressed Ctrl-Alt-Del or Alt-Tab so that I may minimize my program? 在Win32 C ++应用程序中成功登录后,如何删除这些文本框? - How can I remove these textboxes after a successful login in a win32 c++ application? Win32 C++中,如何同时WaitForSingleObject和Detect Ctrl-C? - In Win32 C++, how to WaitForSingleObject and Detect Ctrl-C at the same time? 如何从另一个C ++ win32控制台应用程序调用C ++ Win32 DLL - How Can I call a C++ Win32 DLL from another C++ win32 Console Application Win32:C ++:在子窗口中单击后,如何重新聚焦于父窗口? - Win32: C++: How do I re-focus on Parent Window after clicking in a child window? 如何判断当前进程是否为服务(C++、Win32)? - How can I tell if the current process is a service or not (C++, Win32)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM