[英]Programmatically hide an application on windows
Is there a way to programmatically hide an application on windows? 有没有办法以编程方式隐藏Windows上的应用程序? I want to achieve the same thing as the windows+D shortcut, but for a single application.
我希望实现与Windows + D快捷方式相同的功能,但对于单个应用程序。 I want to do this from within that application (application consists of several windows, one of those can't be moved, resized, closed or minimized by the user).
我想在该应用程序中执行此操作(应用程序包含多个窗口,其中一个窗口无法移动,调整大小,关闭或由用户最小化)。 Application is written in c++ and uses Qt for the UI.
应用程序是用c ++编写的,并使用Qt作为UI。
to do so it's so easy: 这样做很容易:
1- retrieve the handle to that window: 1-检索该窗口的句柄:
HWND hChild = GetDlgItem(hWnd, ID_MYCHILD);
2- send to it SW_SHOW either using ShowWindow or via SendMessage: 2-使用ShowWindow或SendMessage发送给它SW_SHOW:
ShowWindow(hChild, SW_HIDE); // hide
ShowWindow(hChild, SW_SHOW); // show
SendMessage(hChild, SW_HIDE, 0, 0); // hide
SendMessage(hChild, SW_SHOW, 0, 0); // show
1 - retrieve the main window with: 1 - 检索主窗口:
HWND hWnd = GetForegroundWindow(void);
2- use the above to hide/show it 2-使用上面隐藏/显示它
ShowWindow(HwndWindow, SW_MINIMIZE);
Here's the MSDN ShowWindow documentation . 这是MSDN ShowWindow文档 。
In addition you may find EnumChildWindows useful for finding all these windows if their handles aren't readily available to you. 此外,如果您的句柄不可用,您可能会发现EnumChildWindows可用于查找所有这些窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.