Mega Code Archive

 
Categories / Delphi / Examples
 

MinimizeAll Shell Command

Title: MinimizeAll Shell Command Question: I was asked how to implement the MinimizeAll feature of the new Win2K shell. Answer: I found that if you import the Microsoft Shell Controls & Automation Type Library, you have this functionality in a component. Select Project..Import Type Library... from the menu Select Microsoft Shell Controls & Automation (version 1.0). Click Install... There will be several components placed on the ActiveX palette tab. Drop a TShell Component on your form or DM and you canMinimize all just by doing this: Shell1.MinimizeAll; /********************************************************************* There are many really cool shell tricks available when you use the TShell Control. *********************************************************************/ procedure TForm1.Shell(sMethod: Integer); begin case sMethod of 0: //Minimizes all windows on the desktop begin Shell1.MinimizeAll; Button1.Tag := Button1.Tag + 1; end; 1: //Displays the Run dialog begin Shell1.FileRun; Button1.Tag := Button1.Tag + 1; end; 2: //Displays the Shut Down Windows dialog begin Shell1.ShutdownWindows; Button1.Tag := Button1.Tag + 1; end; 3: //Displays the Find dialog begin Shell1.FindFiles; Button1.Tag := Button1.Tag + 1; end; 4: //Displays the Date/Time dialog begin Shell1.SetTime; Button1.Tag := Button1.Tag + 1; end; 5: //Displays the Internet Properties dialog begin Shell1.ControlPanelItem('INETCPL.cpl'); Button1.Tag := Button1.Tag + 1; end; 6: //Enables user to select folder from Program Files begin Shell1.BrowseForFolder(0, 'My Programs', 0, 'C:\Program Files'); Button1.Tag := Button1.Tag + 1; end; 7: //Displays the Taskbar Properties dialog begin Shell1.TrayProperties; Button1.Tag := Button1.Tag + 1; end; 8: //Un-Minimizes all windows on the desktop begin Shell1.UndoMinimizeAll; Button1.Tag := 0; end; end; {case} end; procedure TForm1.Button1Click(Sender: TObject); begin Shell(Button1.Tag); end;