【发布时间】:2011-11-23 22:06:38
【问题描述】:
我想最小化系统中运行的所有应用程序,除了我的。 我怎样才能做到这一点?
我使用了这段代码,但它只适用于一些计算机:
procedure MinAllWnd_ByShell;
VAR IntHwnd: Integer;
begin
IntHwnd:= FindWindow('Shell_TrayWnd', nil);
PostMessage(IntHwnd, WM_COMMAND, 419, 0);
end;
然后
procedure TFrmMain.btnMinimizeAll_Click(Sender: TObject);
begin
{ Send MINIMIZE message }
MinAllWnd_ByShell; { This sends a message to Windows. Windows sends the minimize signal back to us after a delay }
Delay(150); { We wait few miliseconds to receive the message in our message queue }
Application.ProcessMessages; { By now we should have received the message so we process the queue. }
{ Now self restore }
BringToFront;
ShowWindow(frmMain.Handle, SW_RESTORE);
end;
.
德尔福 XE/Win XP/Win 7
【问题讨论】:
-
419 感觉有点无证...
-
如果您进一步延迟 BringToFront,比如 Delay(1500) 怎么办?
-
如果您无法完全控制该系统上安装的内容,您就无法可靠地执行此操作,也不应该这样做。这与How do I create a topmost window that is never covered by other topmost windows 非常相似
-
与“&显示桌面”相同吗? (即 407)
标签: delphi winapi shell minimize