다음을 통해 공유


Commands2.AddNamedCommand 메서드

환경에 저장되어 다음에 환경을 시작하면 사용할 수 있는 명명된 명령을 만듭니다. 이 명령은 환경을 시작할 때 추가 기능을 로드하지 않아도 사용할 수 있습니다.

네임스페이스:  EnvDTE80
어셈블리:  EnvDTE80(EnvDTE80.dll)

구문

‘선언
Function AddNamedCommand ( _
    AddInInstance As AddIn, _
    Name As String, _
    ButtonText As String, _
    Tooltip As String, _
    MSOButton As Boolean, _
    Bitmap As Integer, _
    ByRef ContextUIGUIDs As Object(), _
    vsCommandDisabledFlagsValue As Integer _
) As Command
Command AddNamedCommand(
    AddIn AddInInstance,
    string Name,
    string ButtonText,
    string Tooltip,
    bool MSOButton,
    int Bitmap,
    ref Object[] ContextUIGUIDs,
    int vsCommandDisabledFlagsValue
)
Command^ AddNamedCommand(
    [InAttribute] AddIn^ AddInInstance, 
    [InAttribute] String^ Name, 
    [InAttribute] String^ ButtonText, 
    [InAttribute] String^ Tooltip, 
    [InAttribute] bool MSOButton, 
    [InAttribute] int Bitmap, 
    [InAttribute] array<Object^>^% ContextUIGUIDs, 
    [InAttribute] int vsCommandDisabledFlagsValue
)
abstract AddNamedCommand : 
        AddInInstance:AddIn * 
        Name:string * 
        ButtonText:string * 
        Tooltip:string * 
        MSOButton:bool * 
        Bitmap:int * 
        ContextUIGUIDs:Object[] byref * 
        vsCommandDisabledFlagsValue:int -> Command
function AddNamedCommand(
    AddInInstance : AddIn, 
    Name : String, 
    ButtonText : String, 
    Tooltip : String, 
    MSOButton : boolean, 
    Bitmap : int, 
    ContextUIGUIDs : Object[], 
    vsCommandDisabledFlagsValue : int
) : Command

매개 변수

  • AddInInstance
    형식: AddIn

    필수 요소. AddIn 새 명령을 추가 하는 개체입니다.

  • Name
    형식: String

    필수 요소. 새 명령의 약식 이름입니다. AddNamedCommand는 이 앞에 "Addins.Progid."를 추가하여 고유한 이름을 만듭니다.

  • ButtonText
    형식: String

    필수 요소. 아이콘 대신 이름으로 표시되는 단추에 명령을 바인딩하는 경우 사용하는 이름입니다.

  • Tooltip
    형식: String

    필수 요소. 새 명령에 연결된 컨트롤 위에 마우스 포인터를 두는 경우 표시되는 텍스트입니다.

  • MSOButton
    형식: Boolean

    필수 요소. 항상 false.

  • Bitmap
    형식: Int32

    선택적 요소. 단추에 표시되는 비트맵의 ID입니다.

  • ContextUIGUIDs
    형식: array<Object[]%

    선택적 요소. 표시 된 명령 있는 환경 컨텍스트 (디버그 모드, 디자인 모드 및 등) 확인 하는 Guid

  • vsCommandDisabledFlagsValue
    형식: Int32

    선택적 요소. ContextUIGUIDs를 제공했지만 지정된 컨텍스트가 현재 모두 활성화되지 않은 경우 명령 상태를 확인합니다. 이 매개 변수는 항상 vsCommandStatusSupported를 포함해야 합니다. 이 매개 변수가 vsCommandStatusEnabled도 포함하면 명령을 사용할 수 있습니다.

반환 값

형식: Command
Command 개체

설명

추가 기능으로 QueryStatus 메서드에 응답하여 나중에 ButtonText 이름을 변경할 수 있습니다. 텍스트가 #으로 시작한다면 나머지 문자열은 추가 기능의 등록된 위성 DLL 리소스 ID를 나타내는 정수입니다.

ContextUIGUIDs 매개 변수와 vsCommandStatusValue 매개 변수는 추가 기능이 로드되지 않아 QueryStatus 메서드에 응답할 수 없는 경우 사용됩니다. ContextUIGUIDs가 비어 있으면 추가 기능이 로드되고 QueryStatus에 응답할 수 있을 때까지 명령이 활성 상태입니다.

추가 기능은 IDTCommandTarget 인터페이스를 통해 호출 알림을 수신할 수 있습니다. IDTExtensibility2 인터페이스의 OnConnection 메서드를 사용하여 단추를 추가할 수 있습니다.

예제

Imports Microsoft.VisualStudio.CommandBars
Sub AddControlExample()
   ' Before running, you must add a reference to the Office 
   ' typelib to gain access to the CommandBar object. Also, for this 
   ' example to work correctly, there should be an add-in available 
   ' in the Visual Studio environment.
   Dim cmds As Commands
   Dim cmdobj As Command
   Dim cmdbarobj As CommandBar
   Dim colAddins As AddIns

   ' Set references.
   colAddins = DTE.AddIns()
   cmds = DTE.Commands
   cmdobj = cmds.Item("File.NewFile")

   ' Create a toolbar and add the File.NewFile command to it.
   cmds.AddCommandBar("Mycmdbar", vsCommandBarType.vsCommandBarTypeToolbar)
   MsgBox("Commandbar name: " & cmdbarobj.Name)
   cmdobj.AddControl(cmdbarobj)
   cmds.AddNamedCommand(colAddins.Item(1), "MyCommand", "Button Text", "Some tooltip", True)
End Sub

.NET Framework 보안

참고 항목

참조

Commands2 인터페이스

EnvDTE80 네임스페이스