Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Microsoft Visual C++ .NET Professional Projects - Premier Press

.pdf
Скачиваний:
168
Добавлен:
24.05.2014
Размер:
25.78 Mб
Скачать

x Contents at a Glance

Part VII

Part VII

Part IX

Part X

Part XI

Part XII

18 Introduction to Attribute Based Programming. . . . . . . . . 597 19 Implementing COM Using ATL . . . . . . . . . . . . . . . . . . 607

Professional Project – 6 . . . . . . . . . . . . . . .

633

20

Introduction to ATL Server. . . . . . . . . . . . . . . . . . . . . .

. 637

21

Creating a Guest Book Application . . . . . . . . . . . . . . . .

. 647

 

Y

 

Professional Project – 7 . . . . . . . . . . . . . . .

667

 

F

 

22

Introduction to Web Services and Related Technologies

. 671

23

Creating a Web Service Using Managed Extensions . . . . 697

24

Creating a Web ServiceLUsing ATL Server . . . . . . . . . .

. 725

 

A

 

Professional Project – 8 . . . . . . . . . . . . . . .

749

 

E

 

25

Overview of Mssemblies, Manifests in .NET,

 

 

T

 

 

and Interoperability with COM. . . . . . . . . . . . . . . . . . .

. 753

26

Implementation of COM and .NET Interoperability. . .

. 777

27

Using COM+ Services from .NET Assemblies . . . . . . .

. 793

Professional Project – 9 . . . . . . . . . . . . . . .

807

28 XML with VC++.NET . . . . . . . . . . . . . . . . . . . . . . . . . . 811

Professional Project – 10 . . . . . . . . . . . . . . 835

29 Implementing Networking . . . . . . . . . . . . . . . . . . . . . . . 839

30 Introducing Remoting. . . . . . . . . . . . . . . . . . . . . . . . . . . 871

31 Implementing Remoting . . . . . . . . . . . . . . . . . . . . . . . . . 887

Appendixes . . . . . . . . . . . . . . . . . . . . . . . . . 915

A The .NET Vision and Goals . . . . . . . . . . . . . . . . . . . . . . 917 B The .NET Server Family . . . . . . . . . . . . . . . . . . . . . . . . 939 C Namespaces and Attributes . . . . . . . . . . . . . . . . . . . . . . . 957 D Migrating Unmanaged Code to Managed Code . . . . . . . 965 E Basics of C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 975

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 993

Team-Fly®

Contents

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix

PART I INTRODUCING VC++.NET . . . . . . . . . . . . . . . 1

Chapter 1 Basics of .NET Framework . . . . . . . . . . . . . . . . 3

The .NET Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Common Language Runtime . . . . . . . . . . . . . . . . . . . . . . . . . 5 Class Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Code Access Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Introduction to Visual Studio .NET . . . . . . . . . . . . . . . . . . . . . . 12 The Visual Studio .NET IDE . . . . . . . . . . . . . . . . . . . . . . . . 13 Visual C# .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Visual C++ .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Windows Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Web Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Enhanced and New Features of VC++ .NET . . . . . . . . . . . . . . . 17 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Chapter 2 Basics of VC++.NET Programming . . . . . . . . . 19

Overview of MFC Programming . . . . . . . . . . . . . . . . . . . . . . . . 20

Basics of MFC Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Event Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Device Independence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

xii Contents

Chapter 3 Creating a User Interface . . . . . . . . . . . . . . .

49

An Introduction to the MFC Application Wizard . . . . . . . . . . . 50

Starting the MFC Application Wizard . . . . . . . . . . . . . . . . . 50

Creating an Application Framework . . . . . . . . . . . . . . . . . . . 51

Executing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

Customizing an Application Framework . . . . . . . . . . . . . . . . . . . 59

Creating Variables for the Form Controls . . . . . . . . . . . . . . . 61

Transferring Data between Controls and Variables . . . . . . . . . 64

Handling Button Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

Chapter 4 Working with Menus, Dialog Boxes, and

Window Controls . . . . . . . . . . . . . . . . . . . . . . 71

Creating Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

Creating a Menu Resource . . . . . . . . . . . . . . . . . . . . . . . . . . 72

Code to Display a Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

Handling Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

Working with Dialog Boxes and Controls . . . . . . . . . . . . . . . . . . 80

Creating a Modal Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . 82

Creating a Modeless Dialog Box . . . . . . . . . . . . . . . . . . . . . . 92

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

Chapter 5 The Document/View Architecture . . . . . . . . . 99

Taking a Closer Look at the Document/View Architecture . . . . 100

Components in the Document/View Architecture . . . . . . . . 101

Functionality of the Document/View Classes . . . . . . . . . . . . 102

Creating an MDI Application . . . . . . . . . . . . . . . . . . . . . . . . . 113

A Sample MDI Application . . . . . . . . . . . . . . . . . . . . . . . . 114

Enhancing the Application . . . . . . . . . . . . . . . . . . . . . . . . . 116

Revisiting the Flow of Control in a Document/

View-Based Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

Contents xiii

Chapter 6 Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

Basics of Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134

Single-Threaded Applications . . . . . . . . . . . . . . . . . . . . . . . 135

Multithreaded Applications . . . . . . . . . . . . . . . . . . . . . . . . . 135

More About Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

The AfxBeginThread Function for Worker Threads . . . . . . . 138

The AfxBeginThread Function for User-Interface Threads . 140

Creating a Single-Threaded Application . . . . . . . . . . . . . . . 141

Creating a Multithreaded Application . . . . . . . . . . . . . . . . . 143

Terminating Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

Synchronizing Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

CSyncObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

CMutex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

CCriticalSection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

CSemaphore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

CEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

CMultiLock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

CSingleLock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

PART II PROFESSIONAL PROJECT – 1. . . . . . . . . . 155

PROJECT 1 DATABASE PROGRAMMING USING VC++ .NET . . . . . 157

Chapter 7 Database Management Using ODBC –

An Overview . . . . . . . . . . . . . . . . . . . . . . . . 159

Database Communication Mechanisms . . . . . . . . . . . . . . . . . . 160

ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160

DAO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

Choosing a Data Access Technology . . . . . . . . . . . . . . . . . . 161

MFC ODBC Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

The CDatabase Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

The CRecordset Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

xiv Contents

CRecordView Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

Chapter 8 Implementing Data Access Technologies . . . 173

SaveMyMoney Bank – The Case Study . . . . . . . . . . . . . . . . . .

174

SaveMyMoney Bank – The Solution . . . . . . . . . . . . . . . . . . . .

174

Project Life Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

175

Requirements Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . .

176

High-Level Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

177

Low-Level Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

180

Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

183

Integration and Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . .

183

User Acceptance Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

184

The Banking Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

184

Creating the Banking Database . . . . . . . . . . . . . . . . . . . . . .

184

Configuring an ODBC Data Source . . . . . . . . . . . . . . . . . .

188

Creating the SaveMyMoney Application . . . . . . . . . . . . . . .

191

Coding the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . .

205

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

262

Chapter 9 Debugging and Exception Handling in

VC++.NET. . . . . . . . . . . . . . . . . . . . . . . . . . . 263

Exception Handling in MFC Applications . . . . . . . . . . . . . . . . 264

Exception Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264

Debugging VC++.NET Applications . . . . . . . . . . . . . . . . . . . . 268

Basics of Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

Build Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271

Task List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274

Breakpoints Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

Autos Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

Locals Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291

Watch Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291

QuickWatch Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

Contents xv

Other Debugging Windows . . . . . . . . . . . . . . . . . . . . . . . . 293

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294

PART III PROFESSIONAL PROJECT – 2. . . . . . . . . . 297

PROJECT 2 CREATING AN APPLICATION USING MANAGED C++

APPLICATION . . . . . . . . . . . . . . . . . . . . . . . . . . 299

Chapter 10 Introduction to Managed Extensions . . . . . . 301

The C++ Language in .NET . . . . . . . . . . . . . . . . . . . . . . . . . . 303

Programming Using Managed Extensions for C++ . . . . . . . . . . 304

Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306

Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308

Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309

Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309

Boxing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

Creating a GUI Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

ImageConverter – Managed C++ Application . . . . . . . . . . . 311

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317

Chapter 11 Introduction to GDI+, Events, and Delegates 319

Introducing GDI+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320

The Services Offered by GDI+ . . . . . . . . . . . . . . . . . . . . . . 320

New Features of GDI+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

Programming Model Changes . . . . . . . . . . . . . . . . . . . . . . . . . 324

Overloading Methods in GDI+ . . . . . . . . . . . . . . . . . . . . . . 324

Different Methods for Drawing and Filling . . . . . . . . . . . . . 325

Creating Regions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325

Important Classes and Namespaces in GDI+ . . . . . . . . . . . . . . 326

The System.Drawing Namespace . . . . . . . . . . . . . . . . . . . . 326

The Graphics Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329

The Brush Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333

The Pen Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334

xvi Contents

Events and Delegates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336

Introducing Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336

Introducing Delegates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339

Event Handling in Managed Code . . . . . . . . . . . . . . . . . . . 342

The Unified Event Model . . . . . . . . . . . . . . . . . . . . . . . . . . 345

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345

Chapter 12 Creating a Managed Extensions

 

Application . . . . . . . . . . . . . . . . . . . . . . . . .

347

Project Case Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348

The Requirements Analysis Phase . . . . . . . . . . . . . . . . . . . . 349

The Design Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

The Coding and Construction Phase . . . . . . . . . . . . . . . . . . 353

The Testing Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353

The Execution Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355

Coding the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355

Creating the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 355

Creating the User Interface Form . . . . . . . . . . . . . . . . . . . . 355

Creating the Menu for the Application . . . . . . . . . . . . . . . . 360

Creating the Toolbar and Status Bar for the Application . . . 366

Event Handling in the Application . . . . . . . . . . . . . . . . . . . 369

Delegates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374

The Complete Code Listing for the Easy Tool Application . . . . 379

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440

PART IV PROFESSIONAL PROJECT – 3. . . . . . . . . .

441

PROJECT 3 ADO.NET IN MANAGED C++. . . . . . . . . . . . . . . . 443 Chapter 13 Introduction to ADO.NET . . . . . . . . . . . . . . . 445

Data Access Techniques – An Overview . . . . . . . . . . . . . . . . . . 446

Introducing ADO.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450

Features of ADO.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450

Contents xvii

Benefits of ADO.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451

ADO.NET Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452

ADO.NET Components . . . . . . . . . . . . . . . . . . . . . . . . . . 453

ADO.NET and XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468

Chapter 14 Implementing ADO.NET in a Managed C++

Application . . . . . . . . . . . . . . . . . . . . . . . . . 469

Project Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470

Database Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470

Creating the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471

Creating the Account_Detail Table . . . . . . . . . . . . . . . . . . . 471

Creating the BankLogin Table . . . . . . . . . . . . . . . . . . . . . . 472

Creating the Banking Application . . . . . . . . . . . . . . . . . . . . . . 472

Creating a Project in Managed Extensions . . . . . . . . . . . . . . 473

Creating the Login Form . . . . . . . . . . . . . . . . . . . . . . . . . . 474

Creating the Account Details Form . . . . . . . . . . . . . . . . . . . 480

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501

PART V PROFESSIONAL PROJECT – 4. . . . . . . . . . 503

PROJECT 4 CREATING A MANAGED EXTENSIONS CLASS LIBRARY AND USING IT FROM WITHIN AN ASP.NET

APPLICATION . . . . . . . . . . . . . . . . . . . . . . . . . . 505 Chapter 15 Introduction to ASP.NET . . . . . . . . . . . . . . . . 507

The Evolution of ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . 508

Requirements for Creating an ASP Application . . . . . . . . . . . . 511

ASP.NET Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512

Web Forms Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513

Components of Web Forms . . . . . . . . . . . . . . . . . . . . . . . . . 513

Creating Web Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514

IIS Application Root Directory . . . . . . . . . . . . . . . . . . . . . . 520

xviii Contents

The ASP.NET Web Forms Server Controls . . . . . . . . . . . .

522

HTML Server Controls vs. Web Controls . . . . . . . . . . . . . .

523

Adding Server Controls to a Form . . . . . . . . . . . . . . . . . . . .

524

Setting Properties for Web Controls . . . . . . . . . . . . . . . . . .

525

Handling Events of Web Controls . . . . . . . . . . . . . . . . . . . .

527

Validation Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

530

Using Validation Controls . . . . . . . . . . . . . . . . . . . . . . . . . .

531

Using Multiple Validation Controls . . . . . . . . . . . . . . . . . . .

538

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

539

Chapter 16 Creating a Class Library and Using It in an ASP.NET Application. . . . . . . . . . . . . . . . . . . 541

The Tax Calculator Application . . . . . . . . . . . . . . . . . . . . . . . . 542

Project Life Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542

Creating the Managed C++ Class Library . . . . . . . . . . . . . . 544

Creating the ASP.NET Application . . . . . . . . . . . . . . . . . . 547

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554

PART VI PROFESSIONAL PROJECT – 5. . . . . . . . . .

555

PROJECT 5 CREATING A COM COMPONENT USING ATL . . . . . . . 557

Chapter 17 Introduction to COM . . . . . . . . . . . . . . . . . . 559

Evolution of COM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563

What Is COM? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565

Issues Addressed by COM . . . . . . . . . . . . . . . . . . . . . . . . . 566

COM Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567

Types of COM Components . . . . . . . . . . . . . . . . . . . . . . . . 568

The COM Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570

Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571

Role of the Registry in COM . . . . . . . . . . . . . . . . . . . . . . . 585

Instantiating a COM Object . . . . . . . . . . . . . . . . . . . . . . . . 586

Threading in COM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589

Contents xix

Windows DNA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590

COM+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592

In-Memory Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593

Load Balancing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593

Role-based Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593

New Threading Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593

Object Pooling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594

Queued Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594

COM+ Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594

Automatic Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595

Chapter 18 Introduction to Attribute Based

 

Programming . . . . . . . . . . . . . . . . . . . . . . . .

597

Introduction to Attributes and Reflection . . . . . . . . . . . . . . . . . 598

Categories of Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . 599

Custom Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600

Reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606

Chapter 19 Implementing COM Using ATL . . . . . . . . . . . . 607

Art-Shop – An Online Art Gallery . . . . . . . . . . . . . . . . . . . . .

608

Project Life Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

608

Creating the Credit Card Validation Component . . . . . . . . . . .

612

Understanding the Luhn Algorithm . . . . . . . . . . . . . . . . . .

612

Creating the Basic COM Component Using the ATL

 

Project Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

613

Creating the CoClass and Adding Functionality . . . . . . . . .

615

Testing the Component . . . . . . . . . . . . . . . . . . . . . . . . . . . .

627

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

631