ebook img

Writing Add-ins for Visual Studio .NET PDF

531 Pages·2002·14.27 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Writing Add-ins for Visual Studio .NET

Writing Add-ins for Visual Studio .NET LESSMITH APress Media, LLC Writing Add-ins for Visual Studio .NET Copyright © 2002 by Les Smith Originally published by Apress in 2002 All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN 978-1-59059-026-3 ISBN 978-1-4302-1101-3 (eBook) DOI 10.1007/978-1-4302-1101-3 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Technical Reviewer: Bob Flickinger Editorial Directors: Dan Appleman, Peter Blackburn, Gary Cornell, Jason Gilmore, Simon Hayes, Karen Watterson, John Zukowski Managing Editor: Grace Wong Project Manager and Development Editor: Tracy Brown Collins Copy Editor: Nicole LeClerc Production Manager: Kari Brooks Compositor: Impressions Book and Journal Services, Inc. Indexer: Ron Strauss Cover Designer: Kurt Krames Manufacturing Manager: Tom Debolski Marketing Manager: Stephanie Rodriguez The information in this book is distributed on an "as is" basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. Writing a book is not an easy job. Living with a person who is writing a book can be even harder. I dedicate this book to my loving wife, Ellen, who has stuck by me and encouraged me, not only during the months that it took to write this book, but also through the many years ofl aboring in software development, gaining the experience that led to the writing of this book. She encouraged me to keep going when the research I had to do did not seem to yield the data that I needed to con tinue. She stuck by me as I wrote, hour after hour, night after night, on a seemingly endless task. I thank her for her patience, understanding, inspiration, and love. Brief Contents Foreword ..............................................................x iii About the Author .....................................................x v About the Technical Reviewer ......................................x vii Acknowledgments ......................................................x ix Introduction .........................................................x xi Chapter 1 What Is an Add-in? .....................................1 Chapter 2 Getting Started with the Add-in Wizard ............1 5 Chapter 3 The Smart Desktop Add-in ........................... .45 Chapter 4 Debugging an Add-in ..................................8 7 Chapter 5 Manipulating Code in Windows .......................1 13 Chapter 6 Manipulating Controls on Forms ....................1 41 Chapter 7 The User Interface ..................................1 79 Chapter 8 The Macro Explorer and the Macros IDE ............2 37 Chapter 9 Manipulating Projects ...............................2 73 Chapter 10 Multiple Languages in Add-ins .....................3 13 Chapter 11 Handling Automation Events .........................3 57 Chapter 12 Putting It Together: Let's Build a Real Add-in .391 Chapter 13 Migrating VB 6.0 Add-ins to .NET ................. .439 Appendixes ...........................................................4 57 Appendix A Extensibility Objects .............................. .459 Appendix B Quick Reference: How Do I ••• ? ................... .481 Index .................................................................5 07 v Contents Foreword ..............................................................x iii About the Author .....................................................x v About the Technical Reviewer ......................................x vii Acknowledgments ......................................................x ix Introduction .........................................................x xi Chapter 1 What Is an Add-in? ..............................1 What Is Extensibility? ..............................................1 The Extensibility Object Model for Visual Basic and Visual C# Projects ..................... .2 Other New Features of • NET ......................................... 7 Making a VB 6.0 Add-in Work in .NET ...............................9 Summary ...............................................................1 3 Chapter 2 Getting Started with the Add-in Wizard ....................... 15 Creating an Add-in Using the Add-in Wizard .....................1 5 Reviewing the Code Generated by the Wizard .....................2 7 Making Minor Changes to the Add-in ...............................3 0 Running the Add-in ..................................................3 3 Registering the Add-in .............................................3 4 Installing the Add-in ..............................................3 6 Exploring the Connect Class Methods ..............................3 9 Summary ...............................................................4 3 Chapter 3 The Smart Desktop Add-in ................... .45 Deciding When to Add a Feature to an Add-in ................... .46 Enhancing the Add-in .............................................. .47 Summary ...............................................................8 4 vii Contents Chapter 4 Debugging an Add-in ........................... 87 Setting Debug Options ..............................................8 8 Before Beginning a Debugging Session. • • . ........................9 0 Debugging an Add-in ................................................9 4 Error Handling in the Add-in .....................................1 01 Summary ..............................................................1 11 Chapter 5 Manipulating Code in Windows ............. 113 The Documents Collection .........................................1 14 The Document Object ...............................................1 14 Practical Uses for Editor Automation Objects ..................1 21 Cloning a Procedure ...............................................1 26 The Windows Collection ............................................1 36 Summary ..............................................................1 39 Chapter 6 Manipulating Controls on Forms .......... 141 Creating the New Add-in ...........................................1 42 Adding the WinForms Automation Code ............................1 46 Creating the Windows Application Project .......................1 56 Adding Controls to the Form ......................................1 59 Manipulating Controls on the Form ...............................1 63 Adding a Menu to the Form ........................................1 72 Summary ..............................................................1 77 Chapter 7 The User Interface ........................... 179 A Simple UI: DTE Menu Items ......................................1 79 Adding an Add-in DTE Toolbar .....................................1 90 Adding Microsoft Office CommandBarControls ....................1 98 Using a TreeView Form for the UI ............................... .223 Creating a UI in the System Tray ............................... .226 Summary ..............................................................2 36 viii Contents Chapter 8 The Macro Explorer and the Macros IDE ...........................2 37 The Macro Explorer ................................................ .238 Recording a Macro ..................................................2 43 Assigning Shortcut Keys to a Macro ............................. .246 Running Existing Macros ...........................................2 47 The Macros IDE .....................................................2 49 Debugging Macros ...................................................2 50 Enhancing the Smart Desktop Add-in ..............................2 58 Summary ..............................................................2 72 Chapter 9 Manipulating Projects ...................... .273 The Solution Object .............................................. .274 The Project Object .................................................2 79 Maintaining Build Rules ...........................................2 85 Manipulating IDE Tool Windows ....................................3 02 Summary ..............................................................3 11 Chapter 10 Multiple Languages in Add-ins ..........3 13 Visual Studio Integrator Program ................................3 14 External Tools .....................................................3 14 Selecting the Automation Methodology ...........................3 16 Using Multiple Languages in Add-ins ................. ·.· .........3 17 Comparing Visual Basic to C# .....................................3 18 Creating a C# Add-in ..............................................3 25 Using Multiple Languages in the Add-in .........................3 30 Handling Multiple Languages in an Add-in .......................3 34 Running the Code for Multiple Languages ........................3 53 Summary ..............................................................3 55 Chapter 11 Handling Automation Events ..............3 57 Trapping IDE Events ...............................................3 57 Making Good Use of DTE Events ....................................3 82 Summary ..............................................................3 89 ix Contents Chapter 12 Putting It Together: Let's Build a Real Add-in ................ 391 Creating the NET Desktop Add-in .................................3 92 Adding the User Interface ........................................3 93 Setting Up the Toolbar ............................................3 94 Setting Up the Menus ............................................. .401 About Box ...........................................................4 32 Event Handling .....................................................4 35 Summary ..............................................................4 37 Chapter 13 Migrating VB 6.0 Add-ins to .NET ..... .439 Preparing to Migrate an Add-in ................................. .441 Running the Migration Wizard on an Add-in .................... .443 Should I Go All the Way with • NET? ............................. .450 Summary ..............................................................4 56 Appendixes ......................................................... 457 Appendix A Extensibility Objects ..................... .459 Build Objects ..................................... : .................4 59 CodeModel ...........................................................4 60 Commands ............................................................4 64 Debugger ............................................................4 64 Documents ...........................................................4 66 DTE ..................................................................4 67 Project ..............................................................4 72 Solution ............................................................4 74 Window Objects .....................................................4 75 Win Forms ............................................................4 78 Appendix B Quick Reference: How Do I ... ? ........ .481 Get Code from a Code Editor Window ............................. .481 Retrieve a Whole Procedure from a Code Editor Window ........4 82 Put Code Back into a Code Editor Window ....................... .484 X Contents Add a New Method to the End of a Module ....................... .485 Reference Properties of a Form ................................. .485 Change a Property on a Form ..................................... .486 Reference Properties of a Control on a Form .................. .487 Change a Property of a Control on a Form ...................... .488 Reference All of the Selected Controls on a Form ............ .489 Create a Windows Application Project from an Add-in ......... .489 Add an Item to a Project ........................................ .490 Delete an Item from a Project ................................... .490 Add a Menu Item to the IDE ...................................... .490 Add an Add-in Toolbar to the IDE ............................... .491 Add Tool Buttons to a Toolbar ................................... .491 Add Multilevel Menus to the IDE ................................ .491 Capture Events in the IDE ....................................... .491 Add a New Class, Form, or Module ............................... .491 Persist My Own Clipboard Ring ................................... .491 Access the Tool Options Dialog Box Programmatically ..........4 91 Manually Register an Add-in Not Created with the Add-in Wizard on My Computer ..................... .492 Manually Make the Registry Entries for the Add-in Manager Dialog Box for Add-ins Not Created by the Wizard on My Computer .................. .492 Create a Setup Project for an Add-in Not Created on My Computer .................................. .492 Debug an Add-in When I Only Have the Add-in Project ..........4 92 Recognize When a Form Has Been Added to the Project ......... .492 Recognize When a Component Has Been Added to a Form ......... .493 Reload a Component ................................................ .499 Close All Saved Windows in the IDE ..............................5 00 Close and Save All but the Active Document ................... .5 00 Make a Backup Copy of the Current Window ...................... .5 01 Open All Code and Designer Windows ..............................5 02 Use the CodeModel Object to Analyze Code .......................5 03 Display a Variable or Method Declaration Line in a Code Window ...............................................5 05 Index ............................................................... .5 07 xi

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.