?
Solved

Minimize all or Show Desktop

Posted on 2001-09-03
4
Medium Priority
?
315 Views
Last Modified: 2010-04-06
Is it possible to use a windows api call to minimize all windows or to show the windows desktop? I'm using Delphi 5 on Win 98. Thanx!
0
Comment
Question by:skynergy
[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
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
DidierD earned 200 total points
ID: 6450272
Hi,

Try this.

PROCEDURE  MinimizeAll;
BEGIN
    {    +  'M'  MINIMIZES  ALL  WINDOWS,  +'M'
        RESTORES  THEM  }
    KEYBD_EVENT(  VK_LWIN,  MAPVIRTUALKEY(  VK_LWIN,  0),  0,  0  );  
    KEYBD_EVENT(  ORD('M'),  MAPVIRTUALKEY(  ORD('M'),  0),  0,  0  );
    KEYBD_EVENT(  ORD('M'),  MAPVIRTUALKEY(  ORD('M'),  0),  KEYEVENTF_KEYUP,  0  );
    KEYBD_EVENT(  VK_LWIN,  MAPVIRTUALKEY(  VK_LWIN,  0),  KEYEVENTF_KEYUP,  0  );
END;

Didier
0
 
LVL 2

Expert Comment

by:DidierD
ID: 6450282
to do the opposite

procedure  UnMinimizeAll;
begin
    KEYBD_EVENT(  VK_LWIN,  MAPVIRTUALKEY(  VK_LWIN,  0),  0,  0  );
    KEYBD_EVENT(  VK_SHIFT,  MAPVIRTUALKEY(  VK_SHIFT,  0),  0,  0  );
    KEYBD_EVENT(  ORD('M'),  MAPVIRTUALKEY(  ORD('M'),  0),  0,  0  );
    KEYBD_EVENT(  ORD('M'),  MAPVIRTUALKEY(  ORD('M'),  0),  KEYEVENTF_KEYUP,  0  );
    KEYBD_EVENT(  VK_SHIFT,  MAPVIRTUALKEY(  VK_SHIFT,  0),  KEYEVENTF_KEYUP,  0  );
    KEYBD_EVENT(  VK_LWIN,  MAPVIRTUALKEY(  VK_LWIN,  0),  KEYEVENTF_KEYUP,  0  );
end;
0
 
LVL 5

Expert Comment

by:alanwhincup
ID: 6450488
You could do it like this aswell:

First Example:
{This example minimizes or restores the windows depending on if 'Show Desktop.scf' has been ran or not. Remember to add 'ShellAPI' to the uses clause of the unit}
procedure Minimize;
var
  Dir : array [0..MAX_PATH] of Char;
begin
  GetSystemDirectory(Dir, MAX_PATH);
  ShellExecute(Handle, 'Open', PChar(Dir + '\Show Desktop.scf'), nil, nil, SW_SHOWNORMAL);
end;

Second Example:
{This example just minimizes the windows}
procedure Minimize;
var
  H : hWnd;
begin
  H := Handle;
  while H > 0 do
  begin
    if IsWindowVisible(H) then
      PostMessage(H, WM_SYSCOMMAND, SC_MINIMIZE, 0);
    H := GetNextWindow(H,GW_HWNDNEXT);
  end;
end;

Cheers,

Alan
0
 

Author Comment

by:skynergy
ID: 6450501
Thanx for all the help guys!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

770 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