Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Show Desktop

Status
Not open for further replies.

Eggdude

Programmer
May 17, 2002
5
0
0
US
I need to close or hide all the Windows on the screen except for mine. I like how the Show Desktop icon does it but I can't find anyway to do it in Delphi. Does anyone have a simple way to hide all other windows?
 
hi,

this is a simple method to hide all forms and show the desktop.

procedure TForm1.Button1Click(Sender: TObject);
Const KEYEVENTF_KEYUP = $2;
VK_LWIN = $5B; // windows key
begin
// 77 is the character code for the letter 'M'
keybd_event(VK_LWIN, 0, 0, 0); // windows key down
keybd_event(77, 0, 0, 0); // "M"
keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0); // windows key
end;


Steph [bigglasses]
 
Thanks. That works great. I'm trying to get my program to be the only one visible now. I tried doing an Application. Restore right after the Windows+M code but it doesn't work so I'm just putting it in a timer. Do you know why it doesn't work? Is there a better way to do it?
 
I'm guessing that you are sending the "Windows+M" message to your application, but not giving it time to process the message before calling Application.Restore.

Try putting an Application.ProcessMessages after the PostMessage statements, and before the Application.Restore.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top