Solved

# Minimize all or Show Desktop

Posted on 2001-09-03
302 Views
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
Question by:skynergy
• 2

LVL 2

Accepted Solution

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

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

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

ID: 6450501
Thanx for all the help guys!
0

## Featured Post

Question has a verified solution.

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

### 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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.