IContextMenu2

The IContextMenu2 interface is used to either create or merge a context menu associated with a certain object when a client of IContextMenu is supposed to handle messages associated with owner-drawn menu items.

When to Implement

Implement IContexMenu2 if your object is a client of IContextMenu when owner-drawn messages are an issue: Do so if it is possible to receive one of the following messages while calling TrackPopupMenu in the window procedure of the menu's owner window:

WM_INITPOPUP

WM_DRAWITEM

WM_MEASUREITEM

These messages are sent only if a QueryInterface call for an IContextMenu2 interface pointer is successful, indicating that the object supports this interface.

When to Use

You do not call this interface directly. IContextMenu2 is used by the operating system only when it has confirmed that the application is aware of this interface.

Methods in Vtable Order

IUnknown Methods Description
QueryInterface Returns pointers to supported interfaces.
AddRef Increments reference count.
Release Decrements reference count.

IContextMenu2 Methods Description
QueryContextMenu Adds commands to a context menu.
HandleMenuMsg Handles messages related to drawing owner-drawn menu items.
InvokeCommand Carries out a menu command, either in response to user input or otherwise. For an example, see IExtractIcon.
GetCommandString Retrieves the language-independent name of a menu command or the help text for a menu command.