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?
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;
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.