Create a context menu extension processor with C + + Builder

Source: Internet
Author: User
Tags file system

When a user right-clicks a Shell object, the shell displays its context menu. File system objects have a large number of standard menu items, such as "Cut" and "copy," which are the default menu items. If the object is a file and is a member of a file class, you can specify additional menu items in the registry. The shell checks the registry to see if the file type is associated with some context menu handler, and if so, the shell consults the handler to add additional menu items.

Context Menu handler is a shell extension handler that adds commands to an existing context menu. Context menu handler are associated with a particular file class and are called when the context menu of a member of such a file is displayed. By implementing and registering such a handler, you can dynamically add menu items to the object's context menu to customize menus for special objects.

The working principle of context Menu Handler

As a shell extension handler, the context menu handler, like all other handler, is an in-process COM object, where the object is implemented as a dynamic connection library (DLL). In addition to the IUnknown interface, context menus must also export ishellextinit and IContextMenu interfaces, and as a selection, context menus can also export IContextMenu2 and ICONTEXTMENU3, which can implement custom-drawn menu items.

The Ishellextinit interface is used only by the shell to initialize the handler, and the main operation is performed through the handler IContextMenu interface. The shell first invokes Icontextmenu::querycontextmenu, sending a hmenu handle, which is used to add context menus. If the user has selected these newly added command entries, Icontextmenu::getcommandstring will be invoked to get help on the menu and display it on the resource manager's status bar. If the user clicks the handler entry, the shell invokes Icontextmenu::invokecommand so handler can perform the appropriate action.

Implement IContextMenu Interface

1. Realize Querycontextmenu method

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.