Shell programming tips

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.