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
'Usage
Dim instance As IOleComponentUIManager
Dim dwCompRole As UInteger
Dim rclsidActive As Guid
Dim nMenuId As Integer
Dim pos As POINTS()
Dim pCmdTrgtActive As IOleCommandTarget
Dim returnValue As Integer
returnValue = instance.ShowContextMenu(dwCompRole, _
rclsidActive, nMenuId, pos, pCmdTrgtActive)
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
)
function ShowContextMenu(
dwCompRole : uint,
rclsidActive : Guid,
nMenuId : int,
pos : POINTS[],
pCmdTrgtActive : IOleCommandTarget
) : int
Parameters
dwCompRole
Type: System.UInt32[in] Role of the in-place VSPackage object requesting the context menu. For valid dwCompRole values, see OLEROLE.
rclsidActive
Type: System.Guid%[in] Class identifier (CLSID) of the in-place VSPackage object requesting the context menu.
nMenuId
Type: System.Int32[in] Identifies the context menu to be displayed.
pos
Type: array<Microsoft.VisualStudio.Shell.Interop.POINTS[][in] Identifies the screen position for the context menu.
pCmdTrgtActive
Type: Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget[in] Points to the IOleCommandTarget interface to handle the dispatching of active object commands while the context menu is displayed.
Return Value
Type: System.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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
IOleComponentUIManager Interface