共用方式為


IOleInPlaceComponent.GetCntrContextMenu Method

Definition

Allows an in-place VSPackage object assuming the role of main component to override the context menu requested by an object assuming the subcomponent or component control role.

public:
 int GetCntrContextMenu(System::UInt32 dwRoleActiveObj, Guid % rclsidActiveObj, int nMenuIdActiveObj, cli::array <Microsoft::VisualStudio::Shell::Interop::POINTS> ^ pos, [Runtime::InteropServices::Out] Guid % pclsidCntr, cli::array <Microsoft::VisualStudio::Shell::Interop::OLEMENUID> ^ menuid, [Runtime::InteropServices::Out] System::UInt32 % pgrf);
public int GetCntrContextMenu (uint dwRoleActiveObj, ref Guid rclsidActiveObj, int nMenuIdActiveObj, Microsoft.VisualStudio.Shell.Interop.POINTS[] pos, out Guid pclsidCntr, Microsoft.VisualStudio.Shell.Interop.OLEMENUID[] menuid, out uint pgrf);
abstract member GetCntrContextMenu : uint32 * Guid * int * Microsoft.VisualStudio.Shell.Interop.POINTS[] * Guid * Microsoft.VisualStudio.Shell.Interop.OLEMENUID[] * uint32 -> int
Public Function GetCntrContextMenu (dwRoleActiveObj As UInteger, ByRef rclsidActiveObj As Guid, nMenuIdActiveObj As Integer, pos As POINTS(), ByRef pclsidCntr As Guid, menuid As OLEMENUID(), ByRef pgrf As UInteger) As Integer

Parameters

dwRoleActiveObj
UInt32

[in] Specifies the role of the innermost UI active object that contributes the context menu. For a list of valid dwRoleActiveObj values, see OLEROLE.

rclsidActiveObj
Guid

[in] Class identifier (CLSID) of the innermost UI active object that contributes the context menu.

nMenuIdActiveObj
Int32

[in] Identifier of the menu to be contributed. A menu identifier is a combination of a CLSID and an OLEMENUID structure.

pos
POINTS[]

[in] Position in screen coordinates for the context menu.

pclsidCntr
Guid

[out] Class identifier (CLSID) of the context menu to be contributed. If there is no menu to contribute, this parameter should be null.

menuid
OLEMENUID[]

[out] Identifier of the context menu to be contributed. The identifier is an OLEMENUID structure made up of a numeric menu identifier, a character buffer to hold the menu name, and a pointer to the menu. The menu may be specified either with a menu name string or with the ID of a built-in menu of the in-place object assuming the role of main component. The string should be a name of a menu that is known to the environment. If the string does not identify a valid menu name, then no context menu will be displayed. The environment can return a list of valid menu names through the IPerPropertyBrowsing method.

pgrf
UInt32

[out] Flags controlling how the menu should be used. For a list of valid pgrf values, see OLEMENU.

Returns

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

Remarks

COM Signature

From oleipc.idl:

HRESULT IOleInPlaceComponent::GetCntrContextMenu(  
   [in] DWORD dwRoleActiveObj,  
   [in] REFCLSID rclsidActiveObj,  
   [in] LONG nMenuIdActiveObj,  
   [in] REFPOINTS pos,  
   [out] CLSID *pclsidCntr,  
   [out] OLEMENUID *menuid,  
   [out] DWORD *pgrf  
);  

The menuid parameter can only be set to OLEMENU_CNTRMENUONLY; the OLEMENU_MENUMERGE value is not supported.

In-place objects can request the display of a context menu by calling ShowContextMenu. If the caller of ShowContextMenu is an object assuming the role of subcomponent or component control, the environment calls GetCntrContextMenu of the main component in-place object. This call allows the main component in-place object to gain control of the final context menu display. The main component can perform one of the following actions in its implementation of GetCntrContextMenu:

  • Allow the inner object's context menu to be displayed.

  • Not allow any context menu to be displayed.

  • Contribute a container context menu that completely overrides that of the inner object.

  • Contribute a container context menu that is merged with that of the inner object. The container's menu needs to include a special marker at the point where the object's menu is inserted.

If the in-place object sets the OLEMENU_MENUMERGE bit in the pgrf parameter, the container and active object menus will be merged. If the OLEMENU_MENUMERGE bit is not on, the container menu overrides the menu of the active object. That is, the container context menu is displayed without merging the menu of the active object.

Applies to