This documentation is archived and is not being maintained.

IOleComponentUIManager.ShowContextMenu Method

Requests the display of a context menu.

Namespace: Microsoft.VisualStudio.Shell.Interop
Assembly: Microsoft.VisualStudio.Shell.Interop (in microsoft.visualstudio.shell.interop.dll)

int ShowContextMenu (
	[InAttribute] uint dwCompRole,
	[InAttribute] ref Guid rclsidActive,
	[InAttribute] int nMenuId,
	[InAttribute] POINTS[] pos,
	[InAttribute] IOleCommandTarget pCmdTrgtActive
)
int ShowContextMenu (
	/** @attribute InAttribute() */ UInt32 dwCompRole, 
	/** @attribute InAttribute() */ /** @ref */ Guid rclsidActive, 
	/** @attribute InAttribute() */ int nMenuId, 
	/** @attribute InAttribute() */ POINTS[] pos, 
	/** @attribute InAttribute() */ IOleCommandTarget pCmdTrgtActive
)
JScript does not support passing value-type arguments by reference.

Parameters

dwCompRole

[in] Role of the in-place VSPackage object requesting the context menu. For valid dwCompRole values, see OLEROLE.

rclsidActive

[in] Class identifier (CLSID) of the in-place VSPackage object requesting the context menu.

nMenuId

[in] Identifies the context menu to be displayed.

pos

[in] Identifies the screen position for the context menu.

pCmdTrgtActive

[in] Points to the IOleCommandTarget interface to handle the dispatching of active object commands while the context menu is displayed.

Return Value

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

COM Signature

From oleipc.idl:

HRESULT IOleComponentUIManager::ShowContextMenu(
   [in] DWORD dwCompRole,
   [in] REFCLSID rclsidActive,
   [in] LONG nMenuId,
   [in] REFPOINTS pos,
   [in] IOleCommandTarget *pCmdTrgtActive
);

ShowContextMenu can be used by top-level tool objects and in-place VSPackage objects. In-place VSPackage objects must either be the innermost UI active object or a main or subcomponent in the parent chain of the UI active object.

When the context menu is no longer visible, the SOleComponentUIManager service returns to dispatching active object commands using the IOleCommandTarget interface of the inner-most active object. This is the object that was last passed in the call to IOleCommandTarget.

Because the IOleCommandTarget interface pointed to by pCmdTrgtActive is used while the context menu is displayed instead of the interface of the currently UI active object, it is possible to display the context menu without taking focus away from a nested control. Before displaying the requested menu, if the request is coming from an object acting as a sub in-place component or a component control, the SOleComponentUIManager service gives the main in-place component a chance to override or merge a container menu with the active object menu.

Invoking the command that the user selects on the context menu occurs before the call to ShowContextMenu returns.

If a VSPackage object acting as a component control wants the main component to display its generic control context menu, the component control calls IOleCommandTarget, supplying its own GUID and the menu identifier COMP_CONTEXTID_CTRLGENERIC. The SOleComponentUIManager service passes these identifiers on to the main component when it calls the object's GetCntrContextMenu. The main component should recognize this menu identifier and respond by suppressing the component control's menu and replacing it with the main component's generic control menu.

Show: