Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Clear Windows Desktop

Posted on 2004-04-22
6
Medium Priority
?
214 Views
Last Modified: 2010-04-05
Hi experts

I need to minimize all windows over my desktop.

Thanks,
0
Comment
Question by:MauricioGaviria
6 Comments
 
LVL 4

Expert Comment

by:llcooljayce
ID: 10895138
Windows Button + M will minimize all windows.  Cheers.

Jayce
0
 
LVL 11

Assisted Solution

by:shaneholmes
shaneholmes earned 250 total points
ID: 10895198
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComObj;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  oShell : OleVariant;


implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
oShell := CreateOleObject('Shell.Application');
oShell.MinimizeAll;
oShell := VarNull;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
oShell := CreateOleObject('Shell.Application');
oShell.UndoMinimizeAll;
oShell := VarNull;
end;

end.

Shane
0
 
LVL 11

Expert Comment

by:calinutz
ID: 10896587
procedure TForm1.Button1Click(Sender: TObject);
const
  b: Boolean = false;
var
  wnd: HWND;
begin
  wnd := FindWindow('progman', nil);
  if wnd <> 0 then
  begin
    if b then
      ShowWindow(wnd, SW_SHOW)
    else
      ShowWindow(wnd, SW_HIDE);
    b := not b;
  end
  else
    showmessage('Desktop not found');
end;
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10896966
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

function EnumWindowsFunc (Handle: HWND; List: TStringList) : Boolean ; stdcall;
begin
  if IsWindowVisible(Handle) then
    SendMessage(Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
  Result := True;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  EnumWindows(@EnumWindowsFunc, 0);
end;

end.
0
 
LVL 11

Expert Comment

by:calinutz
ID: 10897566
sorry... I missunderstood the question...my code hides the entire desktop (icons).
It was too early in the morning...
0
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 250 total points
ID: 10898234

// just minimize all visible windows
procedure TForm1.Button1Click(Sender: TObject);
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;


// Or Simulate Win + M:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Keybd_event(VK_LWIN, 0, 0, 0);
  Keybd_event(Byte('M'), 0, 0, 0);
  Keybd_event(Byte('M'), 0, KEYEVENTF_KEYUP, 0);
  Keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
end;
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

971 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