CommandWindow.DTE Property

Gets the top-level extensibility object.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
ReadOnly Property DTE As DTE
'Usage
Dim instance As CommandWindow 
Dim value As DTE 

value = instance.DTE
DTE DTE { get; }
property DTE^ DTE {
    DTE^ get ();
}
function get DTE () : DTE

Property Value

Type: EnvDTE.DTE
A DTE object.

Remarks

In Visual Studio, the DTE object is the root of the automation model, which other object models often call "Application."

Examples

public void CodeExample(DTE2 dte, AddIn addin)
{
    try
    {
        // Get a reference to a Command window.
        Window win = dte.Windows.Item(EnvDTE.Constants.vsWindowKindCommandWindow);
        CommandWindow cmdWin = (CommandWindow)win.Object;
        // Add some text to the window.
        cmdWin.OutputString("This is a line of text in the CommandWindow TextDocument");
        // Return the contents of the TextDocument and display them.
        TextDocument txtDoc = cmdWin.TextDocument;
        TextSelection txtSel = txtDoc.Selection;
        TextRanges txtRanges = txtSel.TextRanges;
        // Show text in textdocument.
        foreach (TextRange txtRange in txtRanges)
        {
            txtRange.StartPoint.StartOfDocument();
            MessageBox.Show(txtRange.StartPoint.GetText(txtRange.EndPoint));
        }
        // Show the CommandWindow's parent object's caption property
        MessageBox.Show("The Parent window's caption: " + cmdWin.Parent.Caption);
        // Show the application object containing the CommandWindow.
        MessageBox.Show(cmdWin.DTE.Name);
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework Security

See Also

Reference

CommandWindow Interface

CommandWindow Members

EnvDTE Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples