次の方法で共有


IDTCommandTarget.QueryStatus メソッド

指定した名前付きコマンドの現在のステータス (有効、無効、非表示など) を返します。

名前空間:  EnvDTE
アセンブリ:  EnvDTE (EnvDTE.dll 内)

構文

'宣言
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
)

パラメーター

  • CmdName
    型: System.String
    確認するコマンドの名前。

解説

Command オブジェクトとその AddNamedCommand メソッドおよび AddControl メソッド、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 

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

IDTCommandTarget インターフェイス

EnvDTE 名前空間