如何使窗口最小化(30分)

  • 主题发起人 主题发起人 patriot
  • 开始时间 开始时间
P

patriot

Unregistered / Unconfirmed
GUEST, unregistred user!
nt40没有刷屏功能,我想做一个类似的,使当前屏幕上的所有窗口都最小化,如何实现,最好
有代码提示,谢谢赐教!
 
users Windows;
procedure Tmainf.FormShow(Sender: TObject);
var
h: hwnd;
begin
//全部窗口最小化
h := handle;
while h > 0 do
begin
if (IsWindowVisible(h)) and (h <> mainf.handle) then
postmessage(h, wm_syscommand, sc_minimize, 0);
h := GetnextWindow(h, GW_HWNDNEXT);
end;
end;
 
模拟键盘操作: Win键+M [:)]
 
遍历 ShowWindow
呵呵,不过 白衣书生 的回答比较牛
 
执行显示桌面,winexec('显示桌面.scx')
 
在程序中调用 HideDesktopAllWin 就可以啦

{ ShowWinNoAnimate }

function GetAnimation: Boolean;
var
Info: TAnimationInfo;
begin
Info.cbSize := SizeOf(TAnimationInfo);
if SystemParametersInfo(SPI_GETANIMATION, SizeOf(Info), @Info, 0) then
Result := Info.iMinAnimate <> 0 else
Result := False;
end;

procedure SetAnimation(Value: Boolean);
var
Info: TAnimationInfo;
begin
Info.cbSize := SizeOf(TAnimationInfo);
BOOL(Info.iMinAnimate) := Value;
SystemParametersInfo(SPI_SETANIMATION, SizeOf(Info), @Info, 0);
end;

procedure ShowWinNoAnimate(Handle: HWnd; CmdShow: Integer);
var
Animation: Boolean;
begin
Animation := GetAnimation;
if Animation then SetAnimation(False);
ShowWindow(Handle, CmdShow);
if Animation then SetAnimation(True);
end;

procedure HideDesktopAllWin(Sender: TObject);
function EnumWindowsProc (Wnd: HWND; LParam: LPARAM): BOOL; stdcall;
begin
Result := True;
if (IsWindowVisible(Wnd)) and
(GetWindowLong(Wnd, GWL_HWNDPARENT) = 0) and
(GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW = 0) then
begin
ShowWinNoAnimate(Wnd, SW_MINIMIZE);
end;
end;
var
Param : Longint;
begin
Param := 0;
EnumWindows(@EnumWindowsProc , Param);
SetForegroundWindow(FindWindow(PChar('ProgMan'), nil));
SetActiveWindow(FindWindow(PChar('ProgMan'), nil));
end;
 
后退
顶部