[This is preliminary documentation and subject to change.]
Enables a snap-in to add items to a context menu.
HRESULT AddMenuItems(
LPDATAOBJECT piDataObject, // Pointer to a data object
LPCONTEXTMENUCALLBACK piCallback,
// Pointer to callback itf
long * pInsertionAllowed // Pointer to insertion pt flags
);
Value | Meaning |
---|---|
CCM_INSERTIONALLOWED_TOP | Items can be inserted at the top of a context menu. |
CCM_INSERTIONALLOWED_NEW | Items can be inserted in the Create New submenu. |
CCM_INSERTIONALLOWED_TASK | Items can be inserted in the Task submenu. |
CCM_INSERTIONALLOWED_VIEW | Items can be inserted in the toolbar view menu or in the View submenu of the result pane context menu. |
An implementation of IExtendContextMenu::AddMenuItems typically reads the node type and any other parameters needed by calling IDataObject::GetDataHere on piDataObject, then it adds context menu items as appropriate by calling IContextMenuCallback::AddItem on piCallback.
Your snap-in should check the pInsertionsAllowed flags for permission before attempting to add a menu item to the MMC defined insertion points. For example, a snap-in should not add menu items to CCM_INSERTIONPOINTID_PRIMARY_NEW or CCM_INSERTIONPOINTID_3RDPARTY_NEW unless the CCM_INSERTIONALLOWED_NEW flag is set.
These flags allow the following two features:
The primary snap-in should not attempt to set bits in pInsertionAllowed that were originally cleared. Future versions of MMC may use bits not currently defined so the primary snap-in should not change bits not currently defined. Third-party extensions should not attempt to change *pInsertionAllowed at all.
This method should not call AddRef on either the piDataObject pointer or the piCallback pointer, nor should it call the methods of those interfaces after returning. Instead, it should make all necessary calls to the methods of those interfaces before returning. If any of these items is selected, you will be given back the pointer to IDataObject in IExtendContextMenu::Command, so do not keep this pointer after this method returns. You will not be notified if the menu is dismissed without any of your items being selected. In addition, do not query for alternate interfaces from piCallback because the one method, IContextMenuCallback::AddItem, should be sufficient.
IContextMenuCallback, IDataObject, IExtendContextMenu