IDTCommandTarget.QueryStatus Yöntem
Belirtilen komut adında geçerli durumu (etkin, devre dışı bırakılmış, gizli ve diğerleri) döndürür.
Ad alanı: EnvDTE
Derleme: EnvDTE (EnvDTE.dll içinde)
Sözdizimi
'Bildirim
Sub QueryStatus ( _
CmdName As String, _
NeededText As vsCommandStatusTextWanted, _
<OutAttribute> ByRef StatusOption As vsCommandStatus, _
<OutAttribute> ByRef CommandText As Object _
)
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
)
abstract QueryStatus :
CmdName:string *
NeededText:vsCommandStatusTextWanted *
StatusOption:vsCommandStatus byref *
CommandText:Object byref -> unit
function QueryStatus(
CmdName : String,
NeededText : vsCommandStatusTextWanted,
StatusOption : vsCommandStatus,
CommandText : Object
)
Parametreler
CmdName
Tür: StringDenetlemek için komut adı.
NeededText
Tür: EnvDTE.vsCommandStatusTextWantedA vsCommandStatusTextWanted denetiminin dışında bilgi verdi ve bu nedenle, ne tür bilgiler döndürülür belirten sabit.
StatusOption
Tür: EnvDTE.vsCommandStatus%A vsCommandStatus komutu geçerli durumunu belirleme.
CommandText
Tür: Object%Metin, dönmek için vsCommandStatusTextWantedStatus belirtilir.
Notlar
Aşağıdaki örnek Command nesnesi, kendi AddNamedCommand ve AddControl yöntemleri ve IDTCommandTarget arabirimi ve onun (Exec ve QueryStatus) bir komut olarak görüntülenen eklenti nasıl göstermek için yöntemler, araçları menüde Visual Studio.Bu kod bir makro çalışmaz dikkat edin.
Örnekler
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
.NET Framework Güvenliği
- Anında arayanlar için tam güven. Bu üye kısmen güvenilen kodla kullanılamaz. Daha fazla bilgi için bkz. Kısmen Güvenilen Koddan Kitaplıkları Kullanma.