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 the programmable inner object of a toolwindow

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

This article explains how to get the programmable inner object of a Visual Studio .NET toolwindow from an add-in or macro.

More Information

Some Visual Studio toolwindows can be automated using its inner object, which is detailed in the following table:

Window Programmable Object
Solution Explorer EnvDTE.UIHierarchy
Macro Explorer EnvDTE.UIHierarchy
ToolBox EnvDTE.ToolBox
Task List EnvDTE.TaskList
Error List EnvDTE80.ErrorList
Command Window EnvDTE.CommandWindow
Output Window EnvDTE.OutputWindow

Note: the Class View does not provide a programmable object.

There are several ways of getting the programmable object inside a toolwindow:

  • For all Visual Studio versions, first you can get the window from the DTE.Windows collection using the GUID of the window (hard-coded or using the ones defined in EnvDTE.Constants.vsext_wk_XXX, EnvDTE.WindowKinds.vsWindowKindXXX or in EnvDTE80.WindowKinds.vsWindowKindXXX). Then, you can get its Window.Object property:
Dim objWindow As EnvDTE.Window
Dim objToolBox As EnvDTE.ToolBox

objWindow = DTE.Windows.Item(EnvDTE.Constants.vsext_wk_Toolbox)
objToolBox = CType(objWindow.Object, EnvDTE.ToolBox)

To know the actual type returned by Window.Object, see HOWTO: Know the actual type behind a System.__ComObject type returned by an .Object property.

  • For Visual Studio 2005, you can use the EnvDTE80.DTE2.ToolWindows class, which provides some common programable objects and also the GetToolWindow method (which received the toolwindow GUID):
Dim objToolBox As EnvDTE.ToolBox

objToolBox = CType(DTE, DTE2).ToolWindows.ToolBox

objToolBox = CType(CType(DTE, DTE2).ToolWindows.GetToolWindow( _
   EnvDTE.Constants.vsext_wk_Toolbox), EnvDTE.ToolBox)

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