Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Clear Windows Desktop

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

I need to minimize all windows over my desktop.

Thanks,
0
Comment
Question by:MauricioGaviria
[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
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 Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

715 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