These code samples show you how to build VSMacros projects, add-ins, and wizards to make your teams more productive and to customize Visual Studio 2005 to the ways you like to work.
Microsoft has invested heavily in Visual Studio extensibility. This is an important part of Visual Studio because it lets customers easily tailor the tool to their personal working style and enables them to accommodate team practices. You can simply capture several steps in a regular process (for example, for check-ins, creating new projects or forms, or updating code) and make that process available as a single command to invoke. Independent software vendors (ISVs) can implement entirely new features (including groupware, profiling tools, work flow, or life-cycle tools) that fit into Visual Studio 2005 as seamlessly as if they were built into the shipping Visual Studio product.
These code samples show you how to build VSMacros projects, add–ins, and wizards to make your teams more productive and customize Visual Studio 2005 to the ways you like to work. Look for more samples, as well as some white papers and overview documents, in the future.
All of these samples use the Visual Studio automation model, which is free and publicly distributed with Visual Studio 2005. With this automation model, you can do the following:
- Intercept commands when they are invoked, and either provide preprocessing or implement the command yourself.
- Control the solution, projects, and project items by adding or removing them.
- Control the build configurations mechanisms and hook various build events.
- Control a large portion of the text editor.
- Implement commands that help you debug with the debugger objects.
- Control the Windows Forms Designer.
- Create tool windows that behave just like the built-in tool windows for docking and floating.
- Provide content to the Property Browser when items are selected in tool windows.
- Control several of the built-in tool windows (including Task List, Toolbox, Command Window, and Output Window).
- And more...
The Automation Samples setup contains the following samples:
This application wizard is a near duplicate of the Add-in Wizard found in the new project dialog under Other Projects and Extensibility Projects. It adds projects to the solution, items to projects, and uses the Find and text editor object models.
This add-in provides pre and post build rules at the solution and project level for projects implementing the common VS Automation model for projects.
Command Browse Add-in
CmdBrowse is an add-in that walks the command bar structure in the environment, displaying the GUID/ID pair of each command, along with its named command. This information is useful when working with the Office CommandBar object model.
This sample demonstrates how you can implement help for your command so that when the user types your command name into the command line window, information is displayed for the available switches and arguments that can be passed to that command.
Code Window Context Menu
This sample add-in demonstrates how the user can add a custom command to the editor context menu
This sample shows the various CommandBar control types that can be added when creating a Tools Menu option for the add-in. In addition it also demonstrates how to use the Satellite dll to change the icons for the Tools menus added for the commands
This sample shows how you can implement your own statement completion tool. This Add-in will load the accompanying .xml file, and when you type a specific keystroke sequence, that text is replaced with other text supplied from the xml file.
The EventWatcher Add-in will connect to all the core shell event objects, and as each event is fired, information is placed into the output window.
This sample shows how to walk the Project tree and creates a dialog box that lists all the project items for that project. Any item then can be selected and opened in the editor.
This sample demonstrates how to take text from the editor window and build a HTML file using this text, including font and color syntax highlighting information.
This add-in puts a Keybindings command in the Help menu that is similar to the Microsoft Visual C++ 6.0 Keyboard Map Help command.
This add-in lets you add named bookmarks that can be hierarchical organized, with the ability to create folders to store bookmarks.
RegExplore is an add-in that emulates the Registry Editor, but as a tool window within the environment. Some of the object model functionality demonstrated includes:
2) ToolsOptions page
3) ToolsOptions Properties
4) Using a satellite dll for resources
5) Adding custom toolbox items.
ScriptHost hosts the VBScript engine, and allows you to run VBS macros from VC6 in the Visual Studio 2005 IDE.
Solution Explorer Context Menu
This sample add-in demonstrates how the user can add a custom command to the solution explorer and how to dynamically enable and disable the command.
Solution Extender Add-in
This sample demonstrates the use of Automation Extenders to "extend" existing Visual Studio objects with new properties and methods. You can extend property grid display objects as well as automation objects, so that more methods and properties are available to the caller. This sample extends both the Solution property grid display object as well as the DTE.Solution automation object.
Thumbnails Add Item Wizard
This wizard prompts for a directory of JPEG files, adds an HTML page to your project, crunches all of the JPEGs down to thumbnails (by using .NET image classes) and lays them out on the HTML page.
Tools Options Pages
This sample shows how to create a custom options page that will be displayed in the Tools | Options dialog and how to interact with that page. It demonstrates the implementation of EnvDTE.IDTToolsOptionsPage interface.
This add-in demonstrates how to create ToolWindows for Visual Studio 2005
This archive contains unsupported tools to be used with the Visual Studio object model. The following items are currently available:
ExtBrws.dll. Brings up a dialog box that displays all of the late-bound objects available under DTE, DTE.Events, or DTE.Properties.
Spell Check Macro
This is a macro project that does spell-checking using Word components and C# Windows Forms for the UI.
Windows Forms Automation
This add-in demonstrates working with the object model provided by the Windows Forms designer. The add-in will create a new Windows Application project, and use the object model to build up a form.
This wizard demonstrates all the context parameters passed into Add Item, Add Project, and Add SubProject wizards. If you add custom parameters to your wizard's .vsz files, the add-in will display those custom parameters so that you can see how they are passed into the wizard.
Windows Scripting Host
The wsh-vs.js sample demonstrates using Windows Scripting Host to launch Visual Studio. It will create an instance of VS, and add a task item. To use this sample, just double click on it from explorer, or type wsh-vs.js at a Windows command prompt.
This sample creates a wizard that lets you add a template in the Add New Item/Local Project Items dialog to create xml and xsl files.
Supported Operating System
Windows 2000 Service Pack 4, Windows Server 2003 Service Pack 1, Windows XP Service Pack 2
Once you download and run the Setup, you'll be asked to agree to the EULA; then the files will be installed to a location on your hard drive of your choosing.
When you load an Add-in project in Visual Studio 2005, please note you will have to perform additional steps in order to configure the project. These steps are listed in the sample's accompanying readme.txt.