Solved

Minimize all windows

Posted on 2000-02-19
13
275 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
  • 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now