Partager via


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)

Syntax

'Declaration
Function ShowContextMenu ( _
    dwCompRole As UInteger, _
    ByRef rclsidActive As Guid, _
    nMenuId As Integer, _
    pos As POINTS(), _
    pCmdTrgtActive As IOleCommandTarget _
) As Integer
int ShowContextMenu(
    uint dwCompRole,
    ref Guid rclsidActive,
    int nMenuId,
    POINTS[] pos,
    IOleCommandTarget pCmdTrgtActive
)
int ShowContextMenu(
    [InAttribute] unsigned int dwCompRole, 
    [InAttribute] Guid% rclsidActive, 
    [InAttribute] int nMenuId, 
    [InAttribute] array<POINTS>^ pos, 
    [InAttribute] IOleCommandTarget^ pCmdTrgtActive
)
abstract ShowContextMenu : 
        dwCompRole:uint32 * 
        rclsidActive:Guid byref * 
        nMenuId:int * 
        pos:POINTS[] * 
        pCmdTrgtActive:IOleCommandTarget -> int
function ShowContextMenu(
    dwCompRole : uint, 
    rclsidActive : Guid, 
    nMenuId : int, 
    pos : POINTS[], 
    pCmdTrgtActive : IOleCommandTarget
) : int

Parameters

  • dwCompRole
    Type: UInt32

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

  • rclsidActive
    Type: Guid%

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

  • nMenuId
    Type: Int32

    [in] Identifies the context menu to be displayed.

Return Value

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

Remarks

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.

.NET Framework Security

See Also

Reference

IOleComponentUIManager Interface

Microsoft.VisualStudio.Shell.Interop Namespace