Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Developing visual studio .NET macros and add-ins
PREMIUM
Số trang
460
Kích thước
12.7 MB
Định dạng
PDF
Lượt xem
786

Developing visual studio .NET macros and add-ins

Nội dung xem thử

Mô tả chi tiết

Jeffrey Cogswell

Developing

Visual Studio® .NET

Macros and Add-Ins

Dear Valued Customer,

We realize you’re a busy professional with deadlines to hit. Whether your goal is to learn a new

technology or solve a critical problem, we want to be there to lend you a hand. Our primary objective

is to provide you with the insight and knowledge you need to stay atop the highly competitive and ever￾changing technology industry.

Wiley Publishing, Inc., offers books on a wide variety of technical categories, including security, data

warehousing, software development tools, and networking — everything you need to reach your peak.

Regardless of your level of expertise, the Wiley family of books has you covered.

• For Dummies® – The fun and easy way™ to learn

• The Weekend Crash Course® –The fastest way to learn a new tool or technology

• Visual – For those who prefer to learn a new topic visually

• The Bible – The 100% comprehensive tutorial and reference

• The Wiley Professional list – Practical and reliable resources for IT professionals

The book you now hold, Developing Visual Studio®.NET Macros and Add-Ins, is your complete guide to

customizing the Visual Studio development environment. With this book, you will be able to automate

routine tasks, build custom interfaces, use Office objects, and much more — using any Visual Studio￾enabled language — to make this powerful development tool even more responsive and better suited to

the needs of your development process.

Our commitment to you does not end at the last page of this book. We’d want to open a dialog with

you to see what other solutions we can provide. Please be sure to visit us at www.wiley.com/compbooks

to review our complete title list and explore the other resources we offer. If you have a comment,

suggestion, or any other inquiry, please locate the “contact us” link at www.wiley.com.

Thank you for your support and we look forward to hearing from you and serving your needs again

in the future.

Sincerely,

Richard K. Swadley

Vice President & Executive Group Publisher

Wiley Technology Publishing

WILEY

advantage

The

Developing Visual Studio® .NET

Macros and Add-Ins

Jeffrey Cogswell

Developing

Visual Studio® .NET

Macros and Add-Ins

Publisher: Joe Wikert

Senior Editor: Ben Ryan

Developmental Editor: Adaobi Obi Tulton

Editorial Manager: Kathryn Malm

Production Editors: Micheline Frederick/Felicia Robinson

Media Development Specialist: Megan Decraene

Text Design & Composition: Wiley Composition Services

This book is printed on acid-free paper. ∞

Copyright © 2003 by Jeff Cogswell. All rights reserved.

Published by Wiley Publishing, Inc., Indianapolis, Indiana

Published simultaneously in Canada

No part of this publication may be reproduced, stored in a retrieval system, or transmitted

in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or

otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright

Act, without either the prior written permission of the Publisher, or authorization through

payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rose￾wood Drive, Danvers, MA, 01923, (978) 750-8400, fax (978) 646-8700. Requests to the

Publisher for permission should be addressed to the Legal Department, Wiley Publishing,

Inc., 10475 Crosspoint Blvd., Indianapolis, IN, 46256, (317) 572-3447, fax (317) 572-4447,

e-mail: [email protected].

Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their

best efforts in preparing this book, they make no representations or warranties with respect

to the accuracy or completeness of the contents of this book and specifically disclaim any

implied warranties of merchantability or fitness for a particular purpose. No warranty may

be created or extended by sales representatives or written sales materials. The advice and

strategies contained herein may not be suitable for your situation. You should consult with

a professional where appropriate. Neither the publisher nor author shall be liable for any

loss of profit or any other commercial damages, including but not limited to special,

incidental, consequential, or other damages.

For general information on our other products and services please contact our Customer

Care Department within the United States at (800) 762-2974, outside the United States at

(317) 572-3993 or fax (317) 572-4002. Trademarks: Wiley, the Wiley Publishing logo, and

related trade dress are trademarks or registered trademarks of Wiley Publishing, Inc., in the

United States and other countries, and may not be used without written permission. Visual

Studio is a trademark or registered trademark of Microsoft Corporation. All other trade￾marks are the property of their respective owners. Wiley Publishing, Inc. is not associated

with any product or vendor mentioned in this book.

Wiley also publishes its books in a variety of electronic formats. Some content that appears

in print may not be available in electronic books.

Library of Congress Cataloging-in-Publication Data:

ISBN: 0-471-23752-3

Printed in the United States of America

10 9 8 7 6 5 4 3 2 1

To all the .NET programmers who are

continually seeking knowledge.

Acknowledgments xiii

About the Author xv

Introduction xvii

Part 1 Automating Your Work 1

Chapter 1 All about Macros and Add-ins 3

What Are Macros and Add-ins? 4

Why Use Macros and Add-ins? 4

Automating Your Work with Macros 5

Enhancing the IDE with Add-ins 7

Online Help for Macros and Add-ins 8

Other Ways to Customize Visual Studio .NET 9

Manipulating the Windows 10

Managing the Toolbars and Commands 17

Customizing the Menus 22

Moving Forward 26

Chapter 2 Just Enough VB.NET 27

VB.NET Subroutines and Functions 29

VB.NET Variables 30

Arrays in VB.NET 34

Strings in VB.NET 36

VB.NET Control Structures 40

Conditional Statements 40

Loop Statements 41

Exceptions 43

Classes in VB.NET 44

Other VB.NET Topics 46

Moving Forward 48

Contents

vii

Chapter 3 Introducing the Visual Studio Macro IDE 49

The Macro System and the Main IDE 49

Macro Development Divisions 51

Projects and Modules 51

Class Files and Code Files 53

Scoping 53

Working with the Macros IDE 54

The Parts of the Macros IDE 55

Managing Projects and Modules 56

Creating a New Project 57

Loading and Unloading Projects 57

Saving Your Project 58

Default Macro Location 59

Creating a New Module 59

Renaming Projects and Modules 59

Deleting a Module 60

Running a Macro 60

Stopping a Macro 61

Using the Code Editor in the Macros IDE 62

Collapsible Code 62

Working with Blocks of Code 63

Debugging a Macro 63

Working with the Macro Explorer 64

Quickly Recording a Temporary Macro 66

Selecting the Recording Project 67

Recording a Macro 67

Editing the Temporary Macro 68

Assigning Shortcut Keys to Your Macros 70

Moving Forward 71

Chapter 4 Macros That Interact with the User 73

Referencing Assemblies and Macro Projects 73

Referencing External Assemblies 74

Referencing Items in Other Macro Projects 75

Referencing One of Your Own Assemblies 77

Creating Windows and Forms 83

Getting Input from a User 83

Creating a Form 84

Displaying Standard Dialog Boxes 85

Working with System Event Handlers 87

Categories of Events 88

Moving Forward 93

Chapter 5 Just Enough .NET Architecture 95

Getting to Know Microsoft .NET 95

Common Language Runtime 96

.NET Class Library 97

viii Contents

Packaging Your Software: Assemblies and Manifests 98

Looking at an Assembly 99

Organizing Multiple Versions of an Assembly 100

.NET and OLE/COM 101

Globally Unique Identifiers 102

Building an Assembly from a COM Component 102

Macro and Add-in Models 103

Visual Studio Packages 104

Visual Studio Project Types 104

Accessing Project Types Not Supported by the Macros IDE 106

Accessing the Project Object 107

Accessing Visual Basic and C# Projects 108

Accessing C++ Projects 109

Macro IDE Automation Model 112

Moving Forward 113

Part 2 Enhancing Visual Studio 115

Chapter 6 Introducing Add-ins 117

About Add-ins 117

Startup and Shutdown 119

Invoking Your Add-in 120

Interacting with the IDE 121

Creating Custom Options Pages 123

Creating Tool Windows 124

Add-ins and the Command System 124

Wizards 125

Add-ins Are COM Components 126

Creating an Add-in 129

Using the Wizard 130

Building and Running the Add-in 136

Managing Add-ins 137

Moving Forward 138

Chapter 7 Creating Add-ins for the IDE 139

Building an Add-in in C++ 139

Including a GUI with Your Add-in 140

Working with Commands 141

Using the Forms Library 141

Building a Tool Window 145

Using the Form Designer with a Tool Window 153

Moving Forward 159

Chapter 8 Life Cycles, Debugging, and Satellite DLLs 161

The Life Cycle of an Add-in 161

Debugging an Add-in 162

Keeping the Registry Clean 163

Debugging the Command-Line Version 163

Debugging the Command-Line Add-in 164

Setting Up Multiple Debug Configurations 165

Contents ix

Creating a Satellite DLL for Resources 167

About Culture-Specific Information 168

Valid Culture Identifiers 169

Adding Culture-Specific Resources in .NET 170

Forms and Multiple Languages 170

Adding Cultural Assemblies in General 171

Making Your Add-ins Multilingual 175

Moving Forward 184

Chapter 9 Manipulating Solutions and Projects 185

Determining the Currently Selected Project 186

Manipulating a Project’s Items 188

Manipulating a Project’s Settings 193

Accessing and Setting Configuration Properties 195

Adding Configurations 198

Configuring Projects at the Solution Level 200

Configuring Individual Files 201

Manipulating Language-Specific Information 205

Moving Forward 206

Chapter 10 Programming the Document and User Interface Objects 207

Managing Documents with the Document Classes 207

The Form Editor and Documents 209

Opening or Creating a Document 210

Processing Text 212

The EditPoint, TextPoint, and VirtualPoint Objects 218

Working with Multiple Windows and Panes 221

Navigating the User Interface Hierarchy 223

Finding a Hierarchy Item 226

Finding an Item Using Regular Expressions 226

Selecting a Hierarchy Item 228

Collapsing Nodes 230

Moving Forward 231

Chapter 11 The CodeModel and Build Objects 233

Manipulating Code with the CodeModel 234

A FileCodeModel Add-in 237

Working with Build Objects 248

Spawning a Build Process 250

Building with the SolutionBuild Object 252

More on the SolutionBuild Object 252

Moving Forward 254

Chapter 12 Creating Project Wizards 255

Dissecting the Wizard Directory Structure 256

Wizard File Interactions and Symbols 259

Rendering the Template Files 263

Wizard Properties 267

A Script Wizard Tutorial 269

x Contents

Creating a Satellite DLL for Resources 167

About Culture-Specific Information 168

Valid Culture Identifiers 169

Adding Culture-Specific Resources in .NET 170

Forms and Multiple Languages 170

Adding Cultural Assemblies in General 171

Making Your Add-ins Multilingual 175

Moving Forward 184

Chapter 9 Manipulating Solutions and Projects 185

Determining the Currently Selected Project 186

Manipulating a Project’s Items 188

Manipulating a Project’s Settings 193

Accessing and Setting Configuration Properties 195

Adding Configurations 198

Configuring Projects at the Solution Level 200

Configuring Individual Files 201

Manipulating Language-Specific Information 205

Moving Forward 206

Chapter 10 Programming the Document and User Interface Objects 207

Managing Documents with the Document Classes 207

The Form Editor and Documents 209

Opening or Creating a Document 210

Processing Text 212

The EditPoint, TextPoint, and VirtualPoint Objects 218

Working with Multiple Windows and Panes 221

Navigating the User Interface Hierarchy 223

Finding a Hierarchy Item 226

Finding an Item Using Regular Expressions 226

Selecting a Hierarchy Item 228

Collapsing Nodes 230

Moving Forward 231

Chapter 11 The CodeModel and Build Objects 233

Manipulating Code with the CodeModel 234

A FileCodeModel Add-in 237

Working with Build Objects 248

Spawning a Build Process 250

Building with the SolutionBuild Object 252

More on the SolutionBuild Object 252

Moving Forward 254

Chapter 12 Creating Project Wizards 255

Dissecting the Wizard Directory Structure 256

Wizard File Interactions and Symbols 259

Rendering the Template Files 263

Wizard Properties 267

A Script Wizard Tutorial 269

x Contents

Tải ngay đi em, còn do dự, trời tối mất!