Compartilhar via


Commands2.AddNamedCommand Method

Definition

Caution

AddIn related extension points are no longer supported in Visual Studio.

Creates a named command that is saved by the environment and made available the next time the environment starts.

EnvDTE::Command AddNamedCommand(EnvDTE::AddIn const & AddInInstance, std::wstring const & Name, std::wstring const & ButtonText, std::wstring const & Tooltip, bool MSOButton, int Bitmap = 0, std::Array <winrt::Windows::Foundation::IInspectable const &> const & & ContextUIGUIDs, int vsCommandDisabledFlagsValue = 16);
[System.Runtime.InteropServices.DispId(11)]
public EnvDTE.Command AddNamedCommand (EnvDTE.AddIn AddInInstance, string Name, string ButtonText, string Tooltip, bool MSOButton, int Bitmap = 0, ref object[] ContextUIGUIDs, int vsCommandDisabledFlagsValue = 16);
[System.Runtime.InteropServices.DispId(11)]
[System.Obsolete("AddIn related extension points are no longer supported in Visual Studio.")]
public EnvDTE.Command AddNamedCommand (EnvDTE.AddIn AddInInstance, string Name, string ButtonText, string Tooltip, bool MSOButton, int Bitmap, ref object[] ContextUIGUIDs, int vsCommandDisabledFlagsValue = 16);
[<System.Runtime.InteropServices.DispId(11)>]
abstract member AddNamedCommand : EnvDTE.AddIn * string * string * string * bool * int * Object[] * int -> EnvDTE.Command
[<System.Runtime.InteropServices.DispId(11)>]
[<System.Obsolete("AddIn related extension points are no longer supported in Visual Studio.")>]
abstract member AddNamedCommand : EnvDTE.AddIn * string * string * string * bool * int * Object[] * int -> EnvDTE.Command
Public Function AddNamedCommand (AddInInstance As AddIn, Name As String, ButtonText As String, Tooltip As String, MSOButton As Boolean, Optional Bitmap As Integer = 0, Optional ByRef ContextUIGUIDs As Object(), Optional vsCommandDisabledFlagsValue As Integer = 16) As Command
Public Function AddNamedCommand (AddInInstance As AddIn, Name As String, ButtonText As String, Tooltip As String, MSOButton As Boolean, Bitmap As Integer, Optional ByRef ContextUIGUIDs As Object(), Optional vsCommandDisabledFlagsValue As Integer = 16) As Command

Parameters

AddInInstance
AddIn

Required. The AddIn object that is adding the new command.

Name
String

Required. The short form of the name for your new command. AddNamedCommand(AddIn, String, String, String, Boolean, Int32, Object[], Int32) prefaces this with "Addins.Progid." to create a unique name.

ButtonText
String

Required. The name to use if the command is bound to a button that is displayed by name rather than by icon.

Tooltip
String

Required. The text displayed when a user hovers the mouse pointer over any control bound to the new command.

MSOButton
Boolean

Required. Should always be false.

Bitmap
Int32

Optional. The ID of a bitmap to display on the button.

ContextUIGUIDs
Object[]

Optional. The GUIDs that determine which environment contexts (that is, debug mode, design mode, and so on) show the command

vsCommandDisabledFlagsValue
Int32

Optional. Determines the state of the command when you supply a ContextUIGUIDs and none of the specified contexts are currently active. This parameter should always include vsCommandStatusSupported. If it also includes vsCommandStatusEnabled, the command will be enabled.

Returns

A Command object.

Implements

Attributes

Remarks

You can later change the ButtonText name by responding to the QueryStatus method. If the text begins with #, then the rest of the string is an integer that represents a resource ID in the registered satellite DLL.

The ContextUIGUIDs parameter and the vsCommandStatusValue parameter are used when the add-in is not loaded and thus cannot respond to the QueryStatus method. If ContextUIGUIDs is empty, then the command is enabled until the add-in is loaded and can respond to QueryStatus.

The addin can receive invocation notification through the IDTCommandTarget interface. A button can be added by using the OnConnection method of the IDTExtensibility2 interface.

Applies to