This note is based on the built-in shellcontrol of Delphi 7Source codeAnalysis, read a lot of MFC implementation class Explorer Shell controls, BCG, cjlib, but do not have Delphi shell control perfect, for example, tshelllistview can automatically obtain language-related characters in the system, such as "name", "size", and "Modify date". In the English system, it is automatically changed to "name", "size ", it feels good! Analyze itsCode, Write down the key points to prevent forgetting. Now the memory is not as good as before.
1. Get the ishellfolder interface of the Desktop Folder object. Subsequent operations depend on it.
Shgetasktopfolder
2. Get idlist by file (folder) name. Many operations in shell programming require idlist.
Ishellfolder: parsedisplayname
3. Get the ishellfolder object interface from idllist
Ishellfolder: bindtoobject
4. The display name is obtained from idlist. For example, disk C may be displayed as "system disk (C :)"
Ishellfolder: getdisplaynameof, strrettostr
5. enumerate folder content, such as files and subdirectories
Ishellfolder: enumobjects
6. The system image list and other information are obtained by the idlist or file (folder) Name.
Shgetfileinfo
You can set imagelists for ctreectrl, clistctrl, and ccomboboxex.
I think customdraw should be used here to set the idlist in itemdata, in getdispinfo
Returns the imagelist index corresponding to each file (folder) object, which is displayed on the interface.
7. Obtain the column title related to the language.
7.1 query the ishellfolder2 interface and QueryInterface from the Desktop Folder object
7.2 ishellfolder2: getdetailsof
7.3 duplicate the previous two steps until the getdetailsof call fails.
8. Right-click the shell menu
8.1 getuiobjectof get icontextmenu object
8.2 create a pop-up menu createpopupmenu
8.3 query contextmenu, icontextmenu: querycontextmenu
8.4 add the tpm_returncmd parameter to the trackpopupmenu pop-up menu
8.5 fill in the cminvokecommandinfo structure based on the returned commandid
8.6 run icontextmenu: invokecommand
These steps are critical. You can combine them to make shell controls. If you don't look at other people's code, you really don't know where to learn, and others are physically active.