OutputWindow.DTE 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取顶级扩展性对象。
public:
property EnvDTE::DTE ^ DTE { EnvDTE::DTE ^ get(); };
public:
property EnvDTE::DTE ^ DTE { EnvDTE::DTE ^ get(); };
[System.Runtime.InteropServices.DispId(2)]
public EnvDTE.DTE DTE { [System.Runtime.InteropServices.DispId(2)] get; }
[<System.Runtime.InteropServices.DispId(2)>]
[<get: System.Runtime.InteropServices.DispId(2)>]
member this.DTE : EnvDTE.DTE
Public ReadOnly Property DTE As DTE
属性值
DTE 对象。
- 属性
示例
Sub DTEExample(ByVal dte As DTE2)
Dim msg As String = _
"The current Output Window object belongs to the "
Dim output As OutputWindow = dte.ToolWindows.OutputWindow
If IsMacrosIDE(output.DTE) Then
MsgBox(msg & "macros IDE.")
Else
MsgBox(msg & "main IDE.")
End If
output = CType(dte.MacrosIDE, DTE2).ToolWindows.OutputWindow
If IsMacrosIDE(output.DTE) Then
MsgBox(msg & "macros IDE.")
Else
MsgBox(msg & "main IDE.")
End If
End Sub
Function IsMacrosIDE(ByVal ide As DTE) As Boolean
Dim val As Boolean = True
Try
' The MacrosIDE property throws an exception if ide
' is not the main DTE object.
If IsNothing(ide.MacrosIDE) = False Then
val = False
End If
Catch ex As Exception
End Try
Return val
End Function
public void DTEExample(DTE2 dte)
{
string msg = "The current Output Window object belongs to the ";
OutputWindow output = dte.ToolWindows.OutputWindow;
if (IsMacrosIDE(output.DTE))
MessageBox.Show(msg + "macros IDE.");
else
MessageBox.Show(msg + "main IDE.");
output = ((DTE2)dte.MacrosIDE).ToolWindows.OutputWindow;
if (IsMacrosIDE(output.DTE))
MessageBox.Show(msg + "macros IDE.");
else
MessageBox.Show(msg + "main IDE.");
}
bool IsMacrosIDE(DTE ide)
{
bool val = true;
try
{
// The MacrosIDE property will throw an exception if ide
// is not the main DTE object.
if (ide.MacrosIDE != null)
val = false;
}
catch (Exception ex)
{
}
return val;
}
注解
在中 Visual Studio , DTE 对象是自动化模型的根,其他对象模型通常会调用 "应用程序"。