Solved

Minimize all or Show Desktop

Posted on 2001-09-03
4
312 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 50 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
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 …

688 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