Solved

Minimize all windows

Posted on 2000-02-19
13
280 Views
Last Modified: 2010-04-04
Hi!

i like to do something speecial in my app, !

How can i minimize all windows?

Karen
0
Comment
Question by:karen021897
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +4
13 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2539038
Hi
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,LongInt(Self));

  { MakeProcInstance for Win16 }
  EnumProc := MakeProcInstance(@NextWindow, HInstance);
  EnumWindows (EnumProc, 0);
  FreeProcInstance(EnumProc);
end;
 

 Regards Barry
0
 
LVL 17

Expert Comment

by:inthe
ID: 2539042
DO NOT TRY ABOVE CODE!!
well expect not good results need to take out some windows first.
back soon.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2539088
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....
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:inthe
ID: 2539094
yep epsylon has the idea using iswindowvisible etc..

there is also another way using a toolhelp snapshot but it wont work on all systems.

0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2539109
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.
0
 
LVL 3

Expert Comment

by:bryan7
ID: 2539313
listenning
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 2539485
Try my TWindowWorks component:

http://www.drdelphi.com/delphi/right/comp.html


Good luck!!

0
 
LVL 20

Accepted Solution

by:
Madshi earned 100 total points
ID: 2539937
This does exactly what Window does:

procedure Shell_MinimizeAllWindows;
var V : Variant;
begin
  V := CreateOleObject('Shell.Application');
  V.MinimizeAll;
end;

But I think it works only with win98 & win2000, or with win95 & NT4 with installed IE4 with system extensions.

Regards, Madshi.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2539940
P.S: I think you need D3-D5 for this to work and add "ComObj" to your uses clause.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2547272
Karen?
0
 
LVL 2

Expert Comment

by:Ten13
ID: 2551512
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;
0
 

Author Comment

by:karen021897
ID: 2562350
I'am going to use Madshi code, so Madshi get the points

thanx
Karen
0
 

Author Comment

by:karen021897
ID: 2562351
good idea...
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question