Solved

Clear Windows Desktop

Posted on 2004-04-22
6
211 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 125 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 125 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
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 this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month5 days, 11 hours left to enroll

627 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