IVsObjectList::GetContextMenu Method (UInt32, Guid, Int32, IOleCommandTarget^)

 

Allows the list to provide a different context menu and IOleCommandTarget for the given list item.

Namespace:   Microsoft.VisualStudio.Shell.Interop
Assembly:  Microsoft.VisualStudio.Shell.Interop (in Microsoft.VisualStudio.Shell.Interop.dll)

int GetContextMenu(
	unsigned int index,
	[OutAttribute] Guid% pclsidActive,
	[OutAttribute] int% pnMenuId,
	[OutAttribute] IOleCommandTarget^% ppCmdTrgtActive
)

Parameters

index
Type: System::UInt32

[in] Specifies the index of the list item of interest.

pclsidActive
Type: System::Guid

[out] Specifies the CLSID of the menu group containing your menu.

pnMenuId
Type: System::Int32

[out] Pointer to an integer containing the menu id.

ppCmdTrgtActive
Type: Microsoft.VisualStudio.OLE.Interop::IOleCommandTarget^

[out] Pointer to the list's or the library's IOleCommandTarget interface.

Return Value

Type: System::Int32

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

From vsshell.idl:

HRESULT IVsObjectList::GetContextMenu(
   [in] ULONG Index,
   [out] CLSID *pclsidActive,
   [out] LONG *pnMenuId,
   [out] IOleCommandTarget **ppCmdTrgtActive
);

This method applies to the Class View tool only. You can use this method to specify an alternate context menu and an IOleCommandTarget to handle the commands on the menu when the list item is selected. This IOleCommandTarget gets first priority at handling the command. When multiple items are selected in Class View, this alternate context menu is not used.

Return to top
Show: