karen021897
asked on
Minimize all windows
Hi!
i like to do something speecial in my app, !
How can i minimize all windows?
Karen
i like to do something speecial in my app, !
How can i minimize all windows?
Karen
DO NOT TRY ABOVE CODE!!
well expect not good results need to take out some windows first.
back soon.
well expect not good results need to take out some windows first.
back soon.
Use this:
function NextWindow(Wnd: HWND; param: Cardinal): Boolean; stdcall;
var parent: HWND;
begin
parent := GetWindow(Wnd, GW_OWNER);
if (parent = 0) and (IsWindowVisible(wnd)) then
ShowWindow(wnd, SW_MINIMIZE);
Result := true;
end;
Btw: There is another way by simulating the Windows+m key press....
function NextWindow(Wnd: HWND; param: Cardinal): Boolean; stdcall;
var parent: HWND;
begin
parent := GetWindow(Wnd, GW_OWNER);
if (parent = 0) and (IsWindowVisible(wnd)) then
ShowWindow(wnd, SW_MINIMIZE);
Result := true;
end;
Btw: There is another way by simulating the Windows+m key press....
yep epsylon has the idea using iswindowvisible etc..
there is also another way using a toolhelp snapshot but it wont work on all systems.
there is also another way using a toolhelp snapshot but it wont work on all systems.
Create a file 'minimize.scf' with these contents:
[Shell]
Command=2
IconFile=explorer.exe,3
[Taskbar]
Command=ToggleDesktop
Then use
ShellExecute(0, 'open', 'minimize.scf', nil, nil, SW_HIDE);
to minimize all windows.
[Shell]
Command=2
IconFile=explorer.exe,3
[Taskbar]
Command=ToggleDesktop
Then use
ShellExecute(0, 'open', 'minimize.scf', nil, nil, SW_HIDE);
to minimize all windows.
listenning
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
P.S: I think you need D3-D5 for this to work and add "ComObj" to your uses clause.
Karen?
Hi Karen
If you have an Windows keyboard with those special windows keys, you can press "winkey+M" to minimize all windows and "winkey+shift+M" to undo minimize all windows. Theese two key press you can emulate with this code:
(* clear distracting keys *)
keybd_event(VK_MENU, $00, KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL, $9D,
KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
if MinimizeAllWindows then begin
(* minimize all windows *)
keybd_event(VK_RWIN, $00,
KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(0x4D, $00,
0, 0);
keybd_event(0x4D, $00,
KEYEVENTF_KEYUP, 0);
keybd_event(VK_RWIN, $00,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
end
else begin
(*undo minimize all windows *)
keybd_event(VK_RWIN, 0x00,
KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(VK_SHIFT, 0x00,
0, 0);
keybd_event(0x4D, 0x00,
0, 0);
keybd_event(0x4D, 0x00,
KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, 0x00,
KEYEVENTF_KEYUP, 0);
keybd_event(VK_RWIN, 0x00,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
end;
If you have an Windows keyboard with those special windows keys, you can press "winkey+M" to minimize all windows and "winkey+shift+M" to undo minimize all windows. Theese two key press you can emulate with this code:
(* clear distracting keys *)
keybd_event(VK_MENU, $00, KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL, $9D,
KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
if MinimizeAllWindows then begin
(* minimize all windows *)
keybd_event(VK_RWIN, $00,
KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(0x4D, $00,
0, 0);
keybd_event(0x4D, $00,
KEYEVENTF_KEYUP, 0);
keybd_event(VK_RWIN, $00,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
end
else begin
(*undo minimize all windows *)
keybd_event(VK_RWIN, 0x00,
KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(VK_SHIFT, 0x00,
0, 0);
keybd_event(0x4D, 0x00,
0, 0);
keybd_event(0x4D, 0x00,
KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, 0x00,
KEYEVENTF_KEYUP, 0);
keybd_event(VK_RWIN, 0x00,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
end;
ASKER
I'am going to use Madshi code, so Madshi get the points
thanx
Karen
thanx
Karen
ASKER
good idea...
how about this one:
function NextWindow (Wnd : HWnd;Form : TForm1) : Boolean; export; {$ifdef Win32} stdcall; {$endif}
begin
ShowWindow (Wnd, SW_MINIMIZE);
NextWindow := true; { next window, please }
end;
procedure TForm1.Sample;
var
EnumProc: TFarProc;
begin
{ this works in Win32 }
EnumWindows(@NextWindow,Lo
{ MakeProcInstance for Win16 }
EnumProc := MakeProcInstance(@NextWind
EnumWindows (EnumProc, 0);
FreeProcInstance(EnumProc)
end;
Regards Barry