最小化所有活动窗口 [英] Minimize all Active Windows
本文介绍了最小化所有活动窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序运行时,如何最小化所有其他应用程序窗口.
我只希望在屏幕上显示我的应用程序窗口.应最小化所有其他应用程序.
How can i minimize all other application windows when my application run.
i want only my application window on the screen.all othes applications should be minimized.
推荐答案
作为用户,我永远不会喜欢这种东西.我不希望任何应用程序在未经我同意的情况下将我的其他窗口最小化.
As a user, I would never like such thing. I would not like any application minimizing my other windows without my consent.
并不是一个好主意(为什么只在顶部发送应用程序是不够的?),但是...
您需要能够通过其HWND最小化窗口.为此,请使用P/Invoke和Windows APISetWindowPlacement
,请参见 http ://msdn.microsoft.com/zh-CN/library/ms633544(v = vs.85).aspx [
Not a very good idea (why just sending your application on top is not enough?), but…
You need to be able to minimize a window by its HWND. To do this, use P/Invoke and Windows APISetWindowPlacement
, see http://msdn.microsoft.com/en-us/library/ms633544(v=vs.85).aspx[^]. Let''s assume you did it and wrapped it in a methodMinimizeWindow(System.IntPtr hwnd)
.
Now, where to get all windows?
I would prefer using pure .NET library, not more P/Invoke:
static void MinimizeAll() {
System.Diagnostics.Process thisProcess =
System.Diagnostics.Process.GetCurrentProcess();
System.Diagnostics.Process[] processes =
System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process process in processes) {
if (process == thisProcess) continue;
System.IntPtr handle = process.MainWindowHandle;
if (handle == System.IntPtr.Zero) continue;
MinimizeWindow(handle);
} //loop
} //MinimizeAll
而已.很简单,不是吗?
That''s it. Pretty simple, isn''t it?
拉杰,试试这个!!!一种简单的方法
Hi Raj try this!!!! A simple Way
Shell32.ShellClass objShel = new Shell32.ShellClass();
((Shell32.IShellDispatch4)objShel).ToggleDesktop();
这篇关于最小化所有活动窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文