Ver versión en español    
 
Home
10 Reasons to use MZ-Tools
MZ-Tools 6.0 for VS.NET
Editions
Features
Online Documentation
MZ-Tools SDK
Download
Purchase
Version History (RSS)  
FAQ & Support
MZ-Tools 3.0 for VB6 & VBA
Features
Online Documentation
Download (freeware)
Donations (Paypal)
Version History (RSS)  
FAQ & Support
User Reviews
Community Place
Contact  
For Add-In Developers
About
   
 
User Testimonials

I'm an avid supporter of MZ-Tools. It's a product I couldn't do without and your level of support is outstanding.

Jan Hyde (Visual Basic MVP)

You will soon wonder how you ever lived without it.

Andy Maggs

More user reviews
 
HOWTO: Get an OutputWindowPane to output some string from a Visual Studio add-in or macro

Author: Carlos J. Quintero (Microsoft MVP) Applies to: Microsoft Visual Studio .NET 2002
Date: August 2008   Microsoft Visual Studio .NET 2003
      Microsoft Visual Studio 2005
      Microsoft Visual Studio 2008
Introduction

Visual Studio provides an Output window ("View", "Other Windows", "Output" menu) to show messages, debug information, etc. That window provides several panes that can be selected through a combobox, such as "Source Control", "Build", "Debug", etc.

The automation model (EnvDTE) provides the EnvDTE.OutputWindow, EnvDTE.OutputWindowPanes and EnvDTE.OutputWindowPane classes. When you try to get a specific OutputWindowPane through OutputWindow.OutputWindowPanes.Item(name), it can fail in international versions of Visual Studio since names are localized (while in English an output window pane is "Build", in Spanish is "Generar").

More Information

To get the an instance of EnvDTE.OutputWindow see the following article:

HOWTO: Get the programmable inner object of a toolwindow

Once you have it, you shouldn't retrieve an OutputWindowPane by name since it can be localized in international versions of Visual Studio. Instead, you can use the Guid property of each output pane that identifies uniquely each pane. Microsoft provides some known Guids in the following link ("Output Pane" section):

IDE Guids

If the Guid that you are looking for is not in that list, you can iterate the output panes querying the name and Guid of each pane until you locate the Guid of the pane that you are interested in.

The following macro gets the Build output pane and writes a string to it:

    Sub WriteToBuildOutputPane()

        Const BUILD_OUTPUT_PANE_GUID As String = "{1BD8A850-02D1-11D1-BEE7-00A0C913D1F8}"

        Dim objOutputToolWindow As Window
        Dim objOutputWindow As OutputWindow
        Dim objOutputWindowPane As OutputWindowPane
        Dim objBuildOutputWindowPane As OutputWindowPane

        objOutputToolWindow = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
        objOutputWindow = DirectCast(objOutputToolWindow.Object, OutputWindow)

        For Each objOutputWindowPane In objOutputWindow.OutputWindowPanes
            If objOutputWindowPane.Guid.ToUpper = BUILD_OUTPUT_PANE_GUID Then
                objBuildOutputWindowPane = objOutputWindowPane
                Exit For
            End If
        Next

        If Not (objBuildOutputWindowPane Is Nothing) Then
            objBuildOutputWindowPane.OutputString("My name is " & objBuildOutputWindowPane.Name & ", which can be localized!")
        End If

    End Sub

Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this


MZ-Tools 6.0 for Visual Studio .NET

You can code, design, locate code and document your apps much faster using VB.NET, C#, C++ or Visual J#:

Buy MZ-Tools Now Download MZ-Tools Demo

   Top