search for books and compare prices
Tables of Contents for Beginning Atl Com Programming
Chapter/Section Title
Page #
Page Count
Introduction
1
6
Who This Book Is For
1
1
How To Read This Book
1
1
What You Need To Use This Book
2
1
Windows NT Service Pack 3
2
1
Visual Studio Service Pack 3
2
1
DCOM for Windows 95 1.1
2
1
Internet Explorer
2
1
Microsoft Visual Basic
3
1
Users of Visual C++ 4.x
3
1
Conventions and Terminology Used
3
2
Web Support
4
1
Tell Us What You Think
4
1
Source Code & Keeping Up-to-date
5
2
Errata & Updates
5
2
Chapter 1: An Introduction to COM
7
46
Why COM?
7
2
A One Sentence Description of COM
9
1
The Component Object Model
10
8
Getting An Interface
12
1
Object Lifetime
12
1
IUnknown
13
3
Interface Inheritance
13
1
Rules for Implementing QueryInterface
14
2
Identity
14
1
Predictability
15
1
Reflexivity
15
1
Symmetry
15
1
Transitivity
16
1
Summary
16
1
COM Diagrams
16
1
Identifying Interfaces
16
2
Generating GUIDs
17
1
Versioning
18
1
The Language of COM
18
5
Marshaling
18
1
IDL
19
1
Memory Management
20
1
HRESULT
21
2
HRESULT Tips
23
1
Creating Interfaces in C++
23
3
Macros
24
1
Interface Inheritance in C++
25
1
Creating a Basic COM DLL Server
26
7
MIDL and C++
26
1
Implementing Interfaces
27
6
AddRef and Release
29
1
QueryInterface
30
1
Alert and Display
31
1
Vtable Layout, Casting & Identity
32
1
[iid_is()]
33
1
Summary
33
1
The Other Side
34
1
Initializing COM
35
1
Locating Servers
35
3
Registering a Component
37
1
Creating an Object
38
2
Class Factories
38
1
CoGetClassObject
39
1
Server Lifetime
40
2
Unloading and Locking DLL Servers
40
1
Unloading and Locking EXE Servers
41
1
Interactive Servers
42
1
Completing the Basic COM DLL Server
42
6
The OLE/COM Object Viewer
47
1
Creating a Basic Client
48
2
Summary
50
3
Chapter 2: Building and Calling a COM Object Using ATL
53
50
Using the ATL COM AppWizard
53
3
Server Type
55
1
Allow Merging of Proxy-Stub Code
55
1
Support MFC
55
1
Examining the Generated Code
56
8
The Files
56
8
The Precompiled Header Files
57
2
_WIN32_WINNT
58
1
_ATL_APARTMENT_THREADED
58
1
_Module
59
1
The IDL File
59
2
Custom Build Step
60
1
The Module Definition File
61
1
The Source File
62
2
Building the Server
64
1
Using the ATL Object Wizard
64
3
Names
65
1
Attributes
66
1
Examining the Generated Code
67
5
Registry Scripts
69
2
Changed Files
71
1
Adding Methods and Properties
72
7
Methods and Properties
72
1
Adding Properties
73
3
More Properties
75
1
Implementing the Properties
76
1
Adding Methods
77
2
Creating an ATL Test Client
79
22
Creating the Skeleton
79
6
CExeModule
80
1
_tWinMain()
80
5
_ATL_MIN_CRT
82
1
CoInitialize()
83
1
Init()
83
1
Checking the Command Line
84
1
The Running Server
84
1
CoUninitialize()
85
1
Adding a Dialog
85
3
Displaying the Dialog
88
1
OnCancel()
89
1
Editing the Dialog Resource
89
1
Using MIDL-Generated Files
90
2
Using the Type Library: the #import Statement
92
7
Smart Pointers
94
1
Type Library Items
95
2
Property Data
95
1
Wrapper Methods
96
1
Raw Interface Methods
97
1
Using the Wrappers
97
1
Enabling Exception Handling
98
1
Testing the Server from Visual Basic
99
2
Summary
101
2
Chapter 3: ATL Architecture
103
60
The Structure of an ATL Class
103
3
The Object Map
104
1
CComObject
105
1
CComObjectxxx classes
105
1
The Maps
106
13
The COM Map
106
5
BEGIN_COM_MAP()
107
2
typedef
107
1
_Cache()
107
1
GetUnknown()
108
1
_InternalQueryInterface()
108
1
_GetEntries()
108
1
COM_INTERFACE_ENTRY()
109
1
END_COM_MAP()
110
1
COM Map Summary
111
1
The Object Map
111
8
BEGIN_OBJECT_MAP() and END_OBJECT_MAP()
111
2
_ATL_OBJMAP_ENTRY
112
1
OBJECT_ENTRY()
113
5
pclsid = &clsid
113
1
pfnUpdateRegistry = &class:UpdateRegistry
113
1
pfnGetClassObject = &class::_ClassFactoryCreatorClass: CreateInstance
114
2
pfnCreateInstance =&class::_CreatorClass::CreateInstance
116
1
pCF = NULL and dwRegister = 0
117
1
pfnGetObjectDescription = &class::GetObjectDescription
117
1
Object Map Summary
118
1
Object Creation
119
6
Class Factory Creation in a DLL
120
1
AtlModuleGetClassObject()
120
1
Class Factory Creation in an EXE
121
1
AtlModuleRegisterClassObjects()
121
1
Object Creation in DLLs and EXEs
122
3
Creation Summary
125
1
Adding COM Support to a Dialog
125
16
Create a New Project
125
1
Insert a Dialog Class
126
1
Define the Interface
127
1
Define the Coclass
128
1
Add the Base Classes
129
1
Add the COM Map
129
1
Add Method Implementations
130
1
Create the Registry Script
130
3
Add an Entry to the Object Map
133
1
Compile And Test
133
1
Adding the Code
134
3
FinalConstruct()
134
1
FinalRelease()
134
1
IsWindowVisible()
134
1
get_Visible()
135
1
OnOK() and OnCancel()
135
1
put_Visible()
135
2
Creating a Client
137
2
Singletons
139
1
Limitations
140
1
Example Summary
140
1
Creating Objects
141
7
Client
143
1
Initializing Objects
144
3
Updating the Client
147
1
Example Summary
148
1
Reusability
148
12
Containment
148
1
Aggregation
149
11
The Inner Object in ATL
152
3
GetControllingUnknown()
153
1
Changing the Aggregation Model
154
1
The Outer Object in ATL
155
5
Clients
158
2
Aggregation Summary
160
1
Summary
160
3
Chapter 4: Automation and Error Handling
163
68
Terminology
163
1
The Need for Automation
164
1
Automation Interfaces
165
30
Methods and Properties
165
2
IDispatch
167
1
Dispinterfaces
168
1
IDispatch Methods
169
6
Invoke
170
3
DISPIDs
172
1
Standard DISPIDs
173
1
GetIDsOfNames
173
1
GetTypeInfoCount and GetTypeInfo
174
1
Dual Interfaces
175
2
Type Libraries
177
2
Automation Data Types
179
16
Named Parameters
180
1
VARIANT
181
2
Maintaining Data
182
1
BSTR
183
1
SAFEARRAY
184
11
Example
187
8
Accessing Automation Objects
195
13
C++
195
10
Dual Interface Access
196
1
Access Through IDispatch
196
3
Smart Pointers
199
6
CComPtr
199
1
CComDispatchDriver
200
2
Proxy Generator
202
3
Visual Basic
205
1
Late Binding
205
1
Early Binding
206
1
Java
206
2
Automation with ATL
208
21
IDispatchImpl
209
3
Adding Functionality
212
6
Handling Errors
218
11
C++ Error Client
223
6
Summary
229
2
Chapter 5: Marshaling and Threading
231
56
DLL and EXE Servers
231
1
DLLs
231
1
EXEs
232
1
Marshaling
232
6
MIDL-Produced Marshaling
233
2
Type Library Marshaling
235
2
Custom Marshaling
237
1
Remote Servers
238
6
Surrogates
238
1
Accessing Remote Servers
239
5
Registering a Server for Remote Access
239
3
CoCreateInstanceEx()
242
2
Remote Objects with ATL
244
26
DLL Server
245
6
Moving the Files
251
3
EXE Server
254
3
Proxy-Stub DLL
257
1
Client
258
4
Distributed COM
262
8
RemoteServerName
262
4
CoCreateInstanceEx
266
2
Surrogate
268
2
Security
270
6
Authentication and Authorization
270
2
Server Authorization
272
3
Identity
275
1
Debugging Local Objects
276
1
Threading
277
7
Apartments
277
1
STAs and Message Pumps
278
1
MTAs and Thread Safety
279
1
Threading and Inproc Servers
280
1
ATL and Threading Models
281
2
Initializing COM
282
1
The Global Threading Model
282
1
Manual Marshaling
283
1
Summary
284
3
Chapter 6: Connectable Objects
287
46
Connection Points and Connectable Objects
287
15
A History of Controls
288
1
Callbacks
289
1
Incoming and Outgoing Interfaces
290
1
Connection Topologies
291
2
Connection Points
293
1
Connection Point Container
294
1
ATL and Connection Points
295
2
Adding an Outgoing Interface
297
1
Adding ATL Connection Point Support
298
1
Event Firing Code
299
3
Example: The EventWatcher Class
302
29
The EventWatcher Server Object
302
11
Creating the Project
304
1
Editing the Class
305
2
Creating the Worker Thread
307
4
The Worker Thread Function
311
1
Killing the Worker Thread
312
1
EventCtrl Client Object
313
3
ActiveX Control
314
1
Sink Interface
315
1
Connecting the Two Together
316
7
Calling the Server
316
4
Proxy Generator
320
3
SetEvent
323
5
Resources
323
1
Handling Windows Events
324
3
Testing
327
1
Testing the Whole Example
328
3
Improvements
331
1
Using the Control with Remote Objects
331
1
Summary
331
2
Chapter 7: Properties, Persistence and Collections
333
62
Control Properties
333
14
Custom Properties
334
1
Stock Properties
334
2
Ambient Properties
336
1
Adding Properties to a Control
337
7
Testing the Control
344
2
Changing Properties via Scripting
346
1
Persistence
347
18
Persistence Interfaces
347
3
Property Maps
350
2
Persisting as Part of a Compound Document
352
4
Loading Properties from a Web Page
356
2
Making Object Properties Persistent
358
7
Collections
365
27
Problems with SAFEARRAYs
366
1
Enumerators
367
5
VB Collections
370
2
Writing Collections in C++
372
1
Count
372
1
Item
372
1
_NewEnum
372
1
Add
372
1
Remove
373
1
Other Methods and Properties
373
1
Example: The DeveloperCollection Object
373
19
The Employee and DeveloperCollection Objects
374
10
Testing the DeveloperCollection Class
384
2
The BUObject Object
386
3
Testing the BusinessUnit Class
389
3
Summary
392
3
Chapter 8: A Full Control
395
74
Controls
395
14
Internet Explorer and Full Controls
396
2
Control Implementation
397
1
Drawing a Control
398
6
OnDrawAdvanced()
399
1
Metafiles
399
1
Sizing & Positioning Controls
400
1
Sizing Example
401
3
Interaction with the Container
404
4
Windowless Controls
404
1
Advise Interfaces
405
2
Connection Points
405
1
IAdviseSink
405
2
Site Interfaces
407
1
Properties Support
407
1
Property Pages
409
6
What Are Property Pages?
411
1
Creating a Property Page
412
3
Add Controls to the Dialog
413
1
Initialize the Page
413
1
Tell the Page Site About Changes
413
1
Update the Control
414
1
Relating the Page to the Control
415
1
Message Maps
415
9
Alternative Message Maps
417
6
Example
418
5
Chaining Message Maps
423
1
Windowless Controls and Message Maps
424
1
Full Control Example
424
43
Tree View Common Controls
426
5
Creating a Tree View Control
428
1
TVITEM Structure
428
1
Adding Items
429
1
Image List Controls
430
1
Querying Values
430
1
Notifications
431
1
Creating the Control
431
2
The Contained Controls
433
3
Sizing the Contained Controls
434
2
Testing the Code
436
1
The URLs Property
437
2
URLTree Tree View Code
439
3
Bitmap Resources
442
1
TVAddItem()
443
4
Testing the Control
447
1
Notification Code
448
2
Internet Explorer
450
1
Persistence Code for IE
451
4
Security Code
454
1
Property Page
455
7
Persistence Code for VB
462
4
Final Notes: Printing
466
1
Summary
467
2
Appendix A: HRESULT Facility Codes
469
4
Index
473