Managing icons on the desktop  

Send By: Q3 Team
Web :
Date: 17/01/03

Tip accessed 515 times


We can treat the desk of the Windos 95 as a ListView, but we would need to obtain a handle to access to him

This function gives us the handle to the ListView that manages the desk:

 	      function GetDesktopListViewHandle: THandle;
                          S: String;
                          Result := FindWindow('ProgMan', nil);
                          Result := GetWindow(Result, GW_CHILD);
                          Result := GetWindow(Result, GW_CHILD);
                          SetLength(S, 40);
                          GetClassName(Result, PChar(S), 39);
                          if PChar(S) <> 'SysListView32' then Result := 0;

So that this serves?

So... suppose that we want to align all the icons from the desk to the left.
We could make it with the following line of code:


We can make many more things with the desk through sending him messages. To know that type of things, look for in the help of the windows Api help the messages LVM_ (In the file win32.hlp that you will have in some place of your HD).
Note: The message constants are defined in commctrl.pas so... you must add commctrl in the uses of your form

Updated at 17/01/2003 (Uses commctrl)