Commands.AddNamedCommand 메서드

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

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.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
    형식: EnvDTE.AddIn

    필수입니다. AddIn 개체가 새 명령을 추가합니다.

  • Name
    형식: String

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

  • ButtonText
    형식: String

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

  • Tooltip
    형식: String

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

  • MSOButton
    형식: Boolean

    필수입니다. 명명된 명령의 단추 그림이 Office 그림인지 여부를 나타냅니다. True이면 단추입니다. MSOButton이 False이면 Bitmap은 Visual C++ 리소스 DLL에 있는 16x16 비트맵 리소스(아이콘 리소스 아님)의 ID이며, 이 DLL은 해당 언어의 로캘 식별자(영어: 1033)와 같은 폴더에 있어야 합니다.

  • Bitmap
    형식: Int32

    선택 사항 단추에 표시되는 비트맵의 ID입니다.

  • ContextUIGUIDs
    형식: array<Object[]%

    선택 사항 명령을 표시하는 환경 컨텍스트(디버그 모드, 디자인 모드 등)를 결정하는 GUID의 SafeArray입니다. vsCommandDisabledFlags를 참조하십시오.

  • vsCommandDisabledFlagsValue
    형식: Int32

반환 값

형식: EnvDTE.Command
Command 개체

설명

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

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

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

예제

' Macro code.
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 보안

참고 항목

참조

Commands 인터페이스

EnvDTE 네임스페이스