Udostępnij za pośrednictwem


OleMenuCommandService Class

Definition

This class derives from the MenuCommandService class and implements IOleCommandTarget. MenuCommandService is the managed class used to add handlers for menu commands and to define verbs.

public ref class OleMenuCommandService : System::ComponentModel::Design::MenuCommandService, Microsoft::VisualStudio::OLE::Interop::IOleCommandTarget
[System.Runtime.InteropServices.ComVisible(true)]
public class OleMenuCommandService : System.ComponentModel.Design.MenuCommandService, Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget
[<System.Runtime.InteropServices.ComVisible(true)>]
type OleMenuCommandService = class
    inherit MenuCommandService
    interface IOleCommandTarget
Public Class OleMenuCommandService
Inherits MenuCommandService
Implements IOleCommandTarget
Inheritance
OleMenuCommandService
Attributes
Implements

Remarks

OleMenuCommandService is automatically offered by the Package class (to offer global commands for an entire package), and it is also offered by the WindowPane class (to offer commands for the current window). This offering is always done via the service container, so anyone deriving from the Package or WindowPane classes can remove or replace the default implementation of this class. This class uses several other services. All of these services are optional, so the class's behavior will degrade if one or more services are missing. The following table shows which services are used and for what purpose:

Service Use
ISelectionService Used to discover the current selection in order to obtain verbs offered by the currently selected designer.
IDesignerHost Used to obtain the designer for the currently selected component, if any.
IVsUIShell Used to notify Visual Studio that the command status has changed.

Used to execute global commands
OleComponentUIManager Used to show context menus

Constructors

OleMenuCommandService(IServiceProvider, IOleCommandTarget)

Creates a new menu command service.

OleMenuCommandService(IServiceProvider)

Creates a new menu command service.

Properties

ParentTarget

Gets or sets the parent command target.

ServiceProvider
Obsolete.

Gets the service provider.

Methods

GlobalInvoke(CommandID, Object)

Can be used to invoke any command within Visual Studio.

GlobalInvoke(CommandID)

Can be used to invoke any command within Visual Studio.

OnCommandsChanged(MenuCommandsChangedEventArgs)

Called by a menu command when its status has changed.

ShowContextMenu(CommandID, Int32, Int32)

Shows the shortcut menu with the given command ID at the given location.

Explicit Interface Implementations

IOleCommandTarget.Exec(Guid, UInt32, UInt32, IntPtr, IntPtr)

Executes the selected command.

IOleCommandTarget.QueryStatus(Guid, UInt32, OLECMD[], IntPtr)

Sets command status.

Applies to