Share via


IDTCommandTarget.QueryStatus 메서드

업데이트: 2007년 11월

지정한 명명된 명령의 현재 상태(사용, 사용 안 함, 숨김 등)를 반환합니다.

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

구문

Sub QueryStatus ( _
    CmdName As String, _
    NeededText As vsCommandStatusTextWanted, _
    <OutAttribute> ByRef StatusOption As vsCommandStatus, _
    <OutAttribute> ByRef CommandText As Object _
)

Dim instance As IDTCommandTarget
Dim CmdName As String
Dim NeededText As vsCommandStatusTextWanted
Dim StatusOption As vsCommandStatus
Dim CommandText As Object

instance.QueryStatus(CmdName, NeededText, _
    StatusOption, CommandText)
void QueryStatus(
    string CmdName,
    vsCommandStatusTextWanted NeededText,
    out vsCommandStatus StatusOption,
    out Object CommandText
)
void QueryStatus(
    [InAttribute] String^ CmdName, 
    [InAttribute] vsCommandStatusTextWanted NeededText, 
    [InAttribute] [OutAttribute] vsCommandStatus% StatusOption, 
    [InAttribute] [OutAttribute] Object^% CommandText
)
function QueryStatus(
    CmdName : String, 
    NeededText : vsCommandStatusTextWanted, 
    StatusOption : vsCommandStatus, 
    CommandText : Object
)

매개 변수

  • CmdName
    형식: System.String

    확인할 명령어 이름입니다.

설명

다음 예제에서는 Command 개체와 이 개체의 AddNamedCommandAddControl 메서드, IDTCommandTarget 인터페이스와 이 인터페이스의 Exec 및 QueryStatus 메서드를 사용하여 추가 기능을 Visual Studio의 도구 메뉴에 명령으로 나타내는 방법을 보여 줍니다. 참고로 이 코드는 매크로에서 동작하지 않습니다.

예제

Implements IDTCommandTarget

Dim applicationObject As EnvDTE.DTE
Dim addInInstance as EnvDTE.AddIn
   
Dim objAddIn As AddIn = CType(addInInst, AddIn)
Dim CommandObj As Command
Try
   CommandObj = applicationObject.Commands.AddNamedCommand(objAddIn, "MyAddin1", "MyAddin1", "Executes the command for MyAddin1", True, 59, Nothing, 1 + 2)
   '1+2 == vsCommandStatusSupported+vsCommandStatusEnabled
   CommandObj.AddControl(applicationObject.CommandBars.Item("Tools"))
Catch e as System.Exception
End Try

Public Sub Exec(ByVal cmdName As String, ByVal executeOption As vsCommandExecOption, ByRef varIn As Object, ByRef varOut As Object, ByRef handled As Boolean) Implements IDTCommandTarget.Exec
   handled = False
   If (executeOption = vsCommandExecOption.vsCommandExecOptionDoDefault) Then
      If cmdName = "MyAddin1.Connect.MyAddin1" Then
         handled = True
         Exit Sub
      End If
   End If
End Sub
   
Public Sub QueryStatus(ByVal cmdName As String, ByVal neededText As vsCommandStatusTextWanted, ByRef statusOption As vsCommandStatus, ByRef commandText As Object) Implements IDTCommandTarget.QueryStatus
   If neededText = EnvDTE.vsCommandStatusTextWanted.vsCommandStatusTextWantedNone Then
      If cmdName = "MyAddin1.Connect.MyAddin1" Then
         statusOption = CType(vsCommandStatus.vsCommandStatusEnabled & vsCommandStatus.vsCommandStatusSupported, vsCommandStatus)
      Else
         statusOption = vsCommandStatus.vsCommandStatusUnsupported
      End If
   End If
End Sub  

권한

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

IDTCommandTarget 인터페이스

IDTCommandTarget 멤버

EnvDTE 네임스페이스