简体   繁体   English

以编程方式隐藏Windows上的应用程序

[英]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
  • if the window doesn't belong to your application then: 如果窗口不属于您的应用程序,则:

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.

相关问题 如何以编程方式隐藏外部程序的窗口? - How to hide an external program's windows programmatically? 有没有办法以编程方式在osx上隐藏Carbon应用程序? - Is there a way to programmatically hide an carbon application on osx? 以编程方式关闭Windows控制台应用程序C ++ - Programmatically close Windows console application c++ 如何在Windows中以编程方式关闭打开的文件/应用程序? - How to programmatically close an open file/application in windows? 在Gnome或KDE中以编程方式在桌面上移动应用程序窗口 - Move application windows on desktop programmatically in Gnome or KDE 如何在普通用户环境中以编程方式在Windows 8上隐藏任务栏? - How to hide the Taskbar on Windows 8 programmatically on a normal user environment? 在Windows窗体应用程序中隐藏控制台窗口 - Hide console window in Windows Forms application 如何以编程方式启动Windows应用商店应用程序? - How do I launch a Windows Store application programmatically? 如何以编程方式将应用程序图标固定到Windows 8中的Metro启动屏幕 - How to pin Application icon to the metro start screen in windows 8 programmatically 具有控制台输出的Qt GUI应用程序-在Windows正常启动时隐藏控制台 - Qt GUI application with console output - hide console on normal startup on Windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM