有人可以帮助我吗? 我想创建一个应用程序,如用户访问控制(UAC)应用程序。当UAC运行时,我们无法点击屏幕上的任何位置,除非我们关闭UAC窗口。此外,我们不能按任何键做任何事情,如窗口键或任何功能键。所以我想创建一个类似的应用程序使用C ++代码来控制键盘和鼠标,只有鼠标和键盘在我的应用程序窗口中启用并禁用外部,除非我不关闭我的应用程序,我不能执行任何其他任务。我的应用程序只是一个带有关闭按钮的图形化简单窗口,以及提到的控件。
答案 0 :(得分:1)
很久以前Windows支持的系统模式对话框。这些将阻止用户与包括桌面在内的其他窗口进行交互。由于它引起的问题,微软很久以前就取消了对此的支持。
现在,当Windows需要为UAC提供系统模式窗口时,他们会使用一些桌面魔法。为了模拟系统模态窗口,UAC做了类似的事情。
现在,他们有一个看起来的桌面,就像它是一个系统模型窗口一样。然后,您可以自由创建一个子窗口来获取用户的输入。下面的示例显示了如何创建桌面并切换到它,应该是您想要做的事情的良好起点
// TODO: Make a copy of the current desktop
// Prepeare a new desktop and activate it
HDESK oldDesktop = GetThreadDesktop(GetCurrentThreadId());
HDESK desktop = CreateDesktop(L"MyDesktop", NULL, NULL, 0, GENERIC_ALL, NULL);
SwitchDesktop(desktop);
// TODO: Create the window that draws the snapshot of the old desktop
// TODO: Create a dialog with buttons and stuff
// Since we don't have a window sit for 5 seconds staring at blank screen
Sleep(5000);
// Switch back to the old desktop and destroy the one we created
// ALERT: If we crash or exit without doing this you will need to
// restart windows
SwitchDesktop(oldDesktop);
CloseDesktop(desktop);
上找到更多信息