[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Minimize all or Show Desktop

Posted on 2001-09-03
4
Medium Priority
?
320 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

650 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