Partager via


IVsObjectList.GetContextMenu Method

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)

Syntax

'Declaration
Function GetContextMenu ( _
    index As UInteger, _
    <OutAttribute> ByRef pclsidActive As Guid, _
    <OutAttribute> ByRef pnMenuId As Integer, _
    <OutAttribute> ByRef ppCmdTrgtActive As IOleCommandTarget _
) As Integer
int GetContextMenu(
    uint index,
    out Guid pclsidActive,
    out int pnMenuId,
    out IOleCommandTarget ppCmdTrgtActive
)
int GetContextMenu(
    [InAttribute] unsigned int index, 
    [OutAttribute] Guid% pclsidActive, 
    [OutAttribute] int% pnMenuId, 
    [OutAttribute] IOleCommandTarget^% ppCmdTrgtActive
)
abstract GetContextMenu : 
        index:uint32 * 
        pclsidActive:Guid byref * 
        pnMenuId:int byref * 
        ppCmdTrgtActive:IOleCommandTarget byref -> int
function GetContextMenu(
    index : uint, 
    pclsidActive : Guid, 
    pnMenuId : int, 
    ppCmdTrgtActive : IOleCommandTarget
) : int

Parameters

  • index
    Type: UInt32

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

  • pclsidActive
    Type: Guid%

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

  • pnMenuId
    Type: Int32%

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

Return Value

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

Remarks

COM Signature

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.

.NET Framework Security

See Also

Reference

IVsObjectList Interface

Microsoft.VisualStudio.Shell.Interop Namespace