Solved

Minimize all or Show Desktop

Posted on 2001-09-03
4
297 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

920 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

15 Experts available now in Live!

Get 1:1 Help Now