Dynamic Context Menus
Static context menus are limited because they are the same for every file object of a given type. Also, the number of files that can be processed through a static menu is limited by the program that is used to carry out the command. What if you need to process 20 files? What if you need different processing options based on the state of the file itself? There are also situations where you might need one context menu for a group of files and another for a single file. This is where dynamic context menus come into play.
A context menu handler is an ActiveX
DLL that implements two interfaces: IShellExtInit
and IContextMenu. A third interface,
IDataObject, is required to implement
IShellExtInit. It is not implemented by the object
itself but exists as a method parameter in
IShellExtInit. We’ll explore these
interfaces in greater depth after we examine how the shell uses a
context menu handler to assemble a context
menu.
The process begins when one or more files is right-clicked in
Explorer. When this occurs, the shell checks the
shellex key under the application identifier key
to see if a context menu handler has been defined for the selected
file type. In the case of the .rad file, the
shell would look under the following key:
HKEY_CLASSES_ROOT/
radfile/
shellex/
ContextMenuHandlers/If you select 15 files that are of all different types, there is still only one file with active focus: the last file selected in the group. It is this file for which the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access