More Ebooks:

Debugging Applications

Database Prog. with VB 5 in 21 Days, 2nd Ed

Database Developer`s Guide with Visual C++ 4, Second Edition

Database Developer`s Guide with VB4, 2nd Edition

Curious About The Internet

Creating Web Applets with Java

Creating Shockwave Web Pages

Configuring Windows 2000 Server Security

Configuring ISA Server 2000 Building Firewalls for Windows 2000

Configuring Citrix Metaframe for Win2000 Terminal Services

find on eBook ToC:

Delphi 5 Developer's Guide (Developer's Guide)

Delphi 5 Developer

Steve Teixeira, Sams

ISBN:0672317818, Edition: , 1999-12-27

Price: $59.99

Table of Contents

Introduction 1

PART I Essentials for Rapid Development ~ 5

1 Windows Programming in Delphi 5 ~ 7
The Delphi Product Family ~ 8
Delphi: What and Why ~ 10
The Quality of the Visual Development Environment ~ 11
The Speediness of the Compiler Versus the Efficiency of the Compiled Code ~ 12
The Power of the Programming Language Versus Its Complexity ~ 13
The Flexibility and Scalability of the Database Architecture ~ 14
The Design and Usage Patterns Enforced by the Framework ~ 14
A Little History ~ 15
Delphi 1 ~ 15
Delphi 2 ~ 16
Delphi 3 ~ 17
Delphi 4 ~ 17
Delphi 5 ~ 18
The Future? ~ 18
The Delphi IDE ~ 19
The Main Window ~ 19
The Form Designer ~ 21
The Object Inspector ~ 21
The Code Editor ~ 22
The Code Explorer ~ 22
A Tour of Your ProjectÆs Source ~ 23
Tour of a Small Application ~ 25
WhatÆs So Great About Events, Anyway? ~ 27
Contract-Free Programming ~ 27
Turbo Prototyping ~ 28
Extensible Components and Environment ~ 28
The Top 10 IDE Features You Must Know and Love ~ 29
1. Class Completion ~ 29
2. AppBrowser Navigation ~ 29
3. Interface/Implementation Navigation ~ 30
4. Dock It! ~ 30
5. A Real Browser ~ 30
6. GUID, Anyone? ~ 30
7. C++ Syntax Highlighting ~ 31
8. To Doà ~ 31
9. Use the Project Manager ~ 31
10. Use Code Insight to Complete Declarations and Parameters ~ 32
Summary ~ 32

2 The Object Pascal Language ~ 33
Comments ~ 34
New Procedure and Function Features ~ 35
Parentheses ~ 35
Overloading ~ 35
Default Value Parameters ~ 35
Variables ~ 36
Constants ~ 38
Operators ~ 40
Assignment Operators ~ 40
Comparison Operators ~ 41
Logical Operators ~ 41
Arithmetic Operators ~ 42
Bitwise Operators ~ 43
Increment and Decrement Procedures ~ 44
Object Pascal Types ~ 44
A Comparison of Types ~ 45
Characters ~ 47
A Multitude of Strings ~ 47
Variant Types ~ 59
Currency ~ 70
User-Defined Types ~ 71
Arrays ~ 71
Dynamic Arrays ~ 72
Records ~ 74
Sets ~ 75
Objects ~ 77
Pointers ~ 78
Type Aliases ~ 81
Typecasting and Type Conversion ~ 82
String Resources ~ 83
Testing Conditions ~ 83
The if Statement ~ 83
Using case Statements ~ 84
Loops ~ 85
The for Loop ~ 85
The while Loop ~ 86
repeat ~ until ~ 87
The Break() Procedure ~ 87
The Continue() Procedure ~ 87
Procedures and Functions ~ 88
Passing Parameters ~ 89
Scope ~ 93
Units ~ 94
The uses Clause ~ 95
Circular Unit References ~ 96
Packages ~ 96
Using Delphi Packages ~ 97
Package Syntax ~ 97
Object-Oriented Programming ~ 97
Object-Based Versus Object-Oriented Programming ~ 99
Using Delphi Objects ~ 100
Declaration and Instantiation ~ 100
Destruction ~ 101
Methods ~ 102
Method Types ~ 102
Properties ~ 105
Visibility Specifiers ~ 105
Inside Objects ~ 107
TObject: The Mother of All Objects ~ 107
Interfaces ~ 108
Structured Exception Handling ~ 112
Exception Classes ~ 115
Flow of Execution ~ 117
Reraising an Exception ~ 119
Runtime Type Information ~ 120
Summary ~ 121

3 The Win32 API ~ 123
Objects - Then and Now ~ 124
Kernel Objects ~ 124
GDI and User Objects ~ 127
Multitasking and Multithreading ~ 128
Win32 Memory Management ~ 129
Just What Is the Flat Memory Model? ~ 130
How Does the Win32 System Manage Memory? ~ 130
Error Handling in Win32 ~ 133
Summary ~ 134

4 Application Frameworks and Design Concepts ~ 135
Understanding the Delphi Environment and Project Architecture ~ 136
Files That Make Up a Delphi 5 Project ~ 137
The Project File ~ 137
Project Unit Files ~ 138
Form Files ~ 138
Resource Files ~ 139
Project Options and Desktop Settings Files ~ 140
Backup Files ~ 140
Package Files ~ 141
Project Management Tips ~ 141
One Project, One Directory ~ 141
Units for Sharing Code ~ 141
Multiple Projects Management (Project Groups) ~ 144
The Framework Classes of a Delphi 5 Project ~ 145
The TForm Class ~ 145
The TApplication Class ~ 153
TApplicationÆs Methods ~ 156
TApplicationÆs Events ~ 158
The TScreen Class ~ 159
Defining a Common Architecture: Using the Object Repository ~ 160
Thoughts on Application Architecture ~ 161
DelphiÆs Inherent Architecture ~ 161
An Architecture Example ~ 162
The Child Form (TChildForm) ~ 162
The Database Base Mode Form (TDBModeForm) ~ 165
The Database Navigation/Status Form (TDBNavStatForm) ~ 167
Using Frames in Application Framework Design ~ 172
Miscellaneous Project Management Routines ~ 174
Adding Resources to Your Project ~ 175
Changing the ScreenÆs Cursor ~ 177
Preventing Multiple Instances of a Form from Being Created ~ 178
Adding Code to the DPR File ~ 179
Overriding the ApplicationÆs Exception Handling ~ 180
Displaying a Splash Screen ~ 182
Minimizing Form Size ~ 184
Running a Formless Project ~ 186
Exiting Windows ~ 186
Preventing Windows Shutdown ~ 188
Summary ~ 189

5 Understanding Windows Messaging ~ 191
What Is a Message? ~ 192
Types of Messages ~ 193
How the Windows Message System Works ~ 194
DelphiÆs Message System ~ 195
Message-Specific Records ~ 196
Handling Messages ~ 197
Message Handling: Not Contract Free ~ 199
Assigning Message Result Values ~ 200
The TApplication TypeÆs OnMessage Event ~ 200
Sending Your Own Messages ~ 201
The Perform() Method ~ 202
The SendMessage() and PostMessage() API Functions ~ 202
Nonstandard Messages ~ 203
Notification Messages ~ 203
Internal VCL Messages ~ 204
User-Defined Messages ~ 205
Anatomy of a Message System: VCL ~ 207
The Relationship Between Messages and Events ~ 214
Summary ~ 215

6 Coding Standards Document ~ 217
Introduction ~ 2 (CD)
General Source Code Formatting Rules ~ 2 (CD)
Indentation ~ 2 (CD)
Margins ~ 2 (CD)
begin ~ end Pair ~ 3 (CD)
Object Pascal ~ 3 (CD)
Parentheses ~ 3 (CD)
Reserved Words and Key Words ~ 3 (CD)
Procedures and Functions (Routines) ~ 4 (CD)
Variables ~ 5 (CD)
Types ~ 6 (CD)
Statements ~ 8 (CD)
Structured Exception Handling ~ 9 (CD)
Classes ~ 10 (CD)
Files ~ 12 (CD)
Project Files ~ 12 (CD)
Form Files ~ 12 (CD)
Data Module Files ~ 13 (CD)
Remote Data Module Files ~ 13 (CD)
Unit Files ~ 13 (CD)
File Headers ~ 14 (CD)
Forms and Data Modules ~ 15 (CD)
Forms ~ 15 (CD)
Data Modules ~ 17 (CD)
Packages ~ 17 (CD)
Use of Runtime Versus Design Packages ~ 17 (CD)
File Naming Standards ~ 17 (CD)
Components ~ 18 (CD)
User-Defined Components ~ 18 (CD)
Component Instance Naming Conventions ~ 18 (CD)
Coding Standards Document Updates ~ 19 (CD)

7 Using ActiveX Controls with Delphi ~ 219
What Is an ActiveX Control? ~ 22 (CD)
Deciding When To Use an ActiveX Control ~ 23 (CD)
Adding an ActiveX Control to the Component Palette ~ 23 (CD)
The Delphi Component Wrapper ~ 26 (CD)
Where Do Wrapper Files Come From? ~ 36 (CD)
Enumerations ~ 36 (CD)
Control Interfaces ~ 36 (CD)
TOleControl Descendant ~ 36 (CD)
The Methods ~ 37 (CD)
The Properties ~ 37 (CD)
Using ActiveX Controls in Your Applications ~ 38 (CD)
Shipping ActiveX ControlûEquipped Applications ~ 40 (CD)
ActiveX Control Registration ~ 40 (CD)
BlackJack: An OCX Application Example ~ 40 (CD)
The Card Deck ~ 41 (CD)
The Game ~ 44 (CD)
Invoking an ActiveX Control Method ~ 54 (CD)
Summary ~ 55 (CD)

PART II Advanced Techniques ~ 221

8 Graphics Programming with GDI and Fonts ~ 223
DelphiÆs Representation of Pictures: TImage ~ 58 (CD)
Saving Images ~ 60 (CD)
Using the TCanvas Properties ~ 62 (CD)
Using Pens ~ 62 (CD)
Using TCanvasÆs Pixels ~ 70 (CD)
Using Brushes ~ 70 (CD)
Using Fonts ~ 77 (CD)
Using the CopyMode Property ~ 78 (CD)
Other Properties ~ 82 (CD)
Using the TCanvas Methods ~ 83 (CD)
Drawing Lines with TCanvas ~ 83 (CD)
Drawing Shapes with TCanvas ~ 84 (CD)
A Code Example for Drawing Shapes ~ 84 (CD)
Painting Text with TCanvas ~ 89 (CD)
Coordinate Systems and Mapping Modes ~ 95 (CD)
Device Coordinates ~ 95 (CD)
Logical Coordinates ~ 96 (CD)
Screen Coordinates ~ 96 (CD)
Form Coordinates ~ 96 (CD)
Coordinate Mapping ~ 97 (CD)
Setting the Mapping Mode ~ 100 (CD)
Setting the Window/Viewport Extents ~ 100 (CD)
Mapping Mode Example Project ~ 102 (CD)
Creating a Paint Program ~ 108 (CD)
How the Paint Program Works ~ 122 (CD)
Performing Animation with Graphics Programming ~ 124 (CD)
Advanced Fonts ~ 134 (CD)
Types of Win32 Fonts ~ 134 (CD)
Basic Font Elements ~ 134 (CD)
GDI Font Categories ~ 136 (CD)
Displaying Different Font Types ~ 138 (CD)
A Font-Creation Sample Project ~ 138 (CD)
How the Project Works ~ 138 (CD)
The TLOGFONT Structure ~ 143 (CD)
Displaying Information About Fonts ~ 146 (CD)
Summary ~ 151 (CD)

9 Dynamic Link Libraries ~ 225
What Exactly Is a DLL? ~ 226
Static Linking Versus Dynamic Linking ~ 228
Why Use DLLs? ~ 230
Sharing Code, Resources, and Data with Multiple Applications ~ 230
Hiding Implementation ~ 230
Custom Controls ~ 231
Creating and Using DLLs ~ 231
Counting Your Pennies (A Simple DLL) ~ 231
Displaying Modal Forms from DLLs ~ 235
Displaying Modeless Forms from DLLs ~ 237
Using DLLs in Your Delphi Applications ~ 239
Loading DLLs Explicitly ~ 241
The Dynamically Linked Library Entry/Exit Function ~ 244
Process/Thread Initialization and Termination Routines ~ 244
DLL Entry/Exit Example ~ 245
Exceptions in DLLs ~ 250
Capturing Exceptions in 16-Bit Delphi ~ 250
Exceptions and the Safecall Directive ~ 251
Callback Functions ~ 251
Using the Callback Function ~ 254
Drawing an Owner-Draw List Box ~ 255
Calling Callback Functions from Your DLLs ~ 255
Sharing DLL Data Across Different Processes ~ 258
Creating a DLL with Shared Memory ~ 259
Using a DLL with Shared Memory ~ 263
Exporting Objects from DLLs ~ 266
Summary ~ 272

10 Printing in Delphi 5 ~ 273
The TPrinter Object ~ 154 (CD)
TPrinter.Canvas ~ 155 (CD)
Simple Printing ~ 156 (CD)
Printing the Contents of a TMemo Component ~ 156 (CD)
Printing a Bitmap ~ 158 (CD)
Printing Rich TextûFormatted Data ~ 159 (CD)
Printing a Form ~ 159 (CD)
Advanced Printing ~ 159 (CD)
Printing a Columnar Report ~ 160 (CD)
Aborting the Printing Process ~ 167 (CD)
Printing Envelopes ~ 168 (CD)
A Simple Print Preview ~ 182 (CD)
Miscellaneous Printing Tasks ~ 184 (CD)
The TDeviceMode Structure ~ 184 (CD)
Specifying Copies to Print ~ 186 (CD)
Specifying Printer Orientation ~ 186 (CD)
Specifying Paper Size ~ 187 (CD)
Specifying Paper Length ~ 187 (CD)
Specifying Paper Width ~ 187 (CD)
Specifying Print Scale ~ 188 (CD)
Specifying Print Color ~ 188 (CD)
Specifying Print Quality ~ 188 (CD)
Specifying Duplex Printing ~ 189 (CD)
Changing the Default Printer ~ 189 (CD)
Obtaining Printer Information ~ 191 (CD)
GetDeviceCaps() and DeviceCapabilities() ~ 191 (CD)
Printer Information Sample Program ~ 192 (CD)
Summary ~ 207 (CD)

11 Writing Multithreaded Applications ~ 275
Threads Explained ~ 276
A New Type of Multitasking ~ 276
Using Multiple Threads in Delphi Applications ~ 277
Misuse of Threads ~ 277
The TThread Object ~ 278
TThread Basics ~ 278
Thread Instances ~ 281
Thread Termination ~ 281
Synchronizing with VCL ~ 283
A Demo Application ~ 286
Priorities and Scheduling ~ 288
Suspending and Resuming Threads ~ 291
Timing a Thread ~ 291
Managing Multiple Threads ~ 293
Thread-Local Storage ~ 293
Thread Synchronization ~ 297
A Sample Multithreaded Application ~ 310
The User Interface ~ 311
The Search Thread ~ 316
Adjusting the Priority ~ 322
Multithreading Database Access ~ 324
Multithreaded Graphics ~ 330
Summary ~ 335

12 Working with Files ~ 337
Dealing with File I/O ~ 338
Working with Text Files ~ 338
Working with Typed Files (Files of Record) ~ 344
Working with Untyped Files ~ 355
The TTextRec and TFileRec Record Structures ~ 360
Working with Memory-Mapped Files ~ 361
Purposes for Memory-Mapped Files ~ 361
Using Memory-Mapped Files ~ 362
Memory-Mapped File Coherence ~ 371
The Text-File Search Utility ~ 371
Directories and Drives ~ 380
Obtaining a List of Available Drives and Drive Types ~ 380
Obtaining Drive Information ~ 381
Obtaining the Location of the Windows Directory ~ 384
Obtaining the Location of the System Directory ~ 384
Obtaining the Name of the Current Directory ~ 385
Searching for a File Across Directories ~ 386
Copying and Deleting a Directory Tree ~ 389
Getting File Version Information ~ 392
Getting the Version Numbers ~ 400
Getting the Operating System Information ~ 401
Using the TVerInfoRes Class ~ 401
Using the SHFileOperation() function ~ 404
Summary ~ 406

13 Hard-Core Techniques ~ 407
Advanced Application Message Handling ~ 408
Subclassing ~ 408
HookMainWindow() ~ 414
Preventing Multiple Application Instances ~ 416
Using BASM with Delphi ~ 421
How Does BASM Work? ~ 422
Easy Parameter Access ~ 423
var Parameters ~ 423
Register Calling Convention ~ 424
All-Assembly Procedures ~ 424
Records ~ 425
Using Windows Hooks ~ 426
Setting the Hook ~ 426
Using the Hook Function ~ 428
Using the Unhook Function ~ 428
Using SendKeys: A JournalPlayback Hook ~ 428
Using C/C++ OBJ Files ~ 443
Calling a Function ~ 444
Name Mangling ~ 445
Sharing Data ~ 445
Using the Delphi RTL ~ 447
Using C++ Classes ~ 452
Thunking ~ 457
Generic Thunking ~ 458
WM_COPYDATA ~ 470
Obtaining Package Information ~ 477
Summary ~ 481

14 Snooping System Information ~ 483
InfoForm: Obtaining General Information ~ 484
Formatting the Strings ~ 485
Obtaining Memory Status ~ 486
Getting the OS Version ~ 488
Obtaining Directory Information ~ 489
Getting System Information ~ 490
Checking Out the Environment ~ 494
Platform-Neutral Design ~ 500
Windows 95/98: Using ToolHelp32 ~ 501
Snapshots ~ 502
Process Walking ~ 503
Thread Walking ~ 507
Module Walking ~ 510
Heap Walking ~ 512
Heap Viewing ~ 515
The Source ~ 517
Windows NT/2000: PSAPI ~ 527
Summary ~ 541

15 Porting to Delphi 5 ~ 543
New to Delphi 5 ~ 210 (CD)
Which Version? ~ 210 (CD)
Units, Components, and Packages ~ 212 (CD)
Migrating from Delphi 4 ~ 212 (CD)
IDE Issues ~ 212 (CD)
RTL Issues ~ 213 (CD)
VCL Issues ~ 213 (CD)
Internet Development Issues ~ 214 (CD)
Database Issues ~ 214 (CD)
Migrating from Delphi 3 ~ 214 (CD)
Unsigned 32-Bit Integers ~ 214 (CD)
64-Bit Integer ~ 216 (CD)
The Real Type ~ 216 (CD)
Migrating from Delphi 2 ~ 216 (CD)
Changes to Boolean Types ~ 216 (CD)
ResourceString ~ 217 (CD)
RTL Changes ~ 217 (CD)
TCustomForm ~ 218 (CD)
GetChildren() ~ 218 (CD)
Automation Servers ~ 218 (CD)
Migrating from Delphi 1 ~ 219 (CD)
Strings and Characters ~ 219 (CD)
Variable Size and Range ~ 227 (CD)
Record Alignment ~ 228 (CD)
32-Bit Math ~ 229 (CD)
The TDateTime Type ~ 229 (CD)
Unit Finalization ~ 229 (CD)
Assembly Language ~ 230 (CD)
Calling Conventions ~ 231 (CD)
Dynamic Link Libraries (DLLs) ~ 231 (CD)
Windows Operating System Changes ~ 233 (CD)
32-Bit Address Space ~ 233 (CD)
32-Bit Resources ~ 234 (CD)
VBX Controls ~ 234 (CD)
Changes to the Windows API Functions ~ 234 (CD)
Concurrent 16-Bit and 32-Bit Projects ~ 237 (CD)
Summary ~ 238 (CD)
16 MDI Applications 545
Creating the MDI Application ~ 240 (CD)
Understanding MDI Basics ~ 240 (CD)
The Child Form ~ 242 (CD)
The Main Form ~ 264 (CD)
Working with Menus ~ 272 (CD)
Merging Menus with MDI Applications ~ 272 (CD)
Adding a List of Open Documents to the Menu ~ 273 (CD)
Miscellaneous MDI Techniques ~ 273 (CD)
Drawing a Bitmap in the MDI Client Window ~ 274 (CD)
Creating a Hidden MDI Child Form ~ 281 (CD)
Minimizing, Maximizing, and Restoring All MDI Child Windows ~ 284 (CD)
Summary ~ 287 (CD)

17 Sharing Information with the Clipboard ~ 547
In the Beginning, There Was the Clipboard ~ 548
Using the Clipboard with Text ~ 549
Using the Clipboard with Images ~ 550
Creating Your Own Clipboard Format ~ 551
Creating a Clipboard-Aware Object ~ 552
Using the Custom Clipboard Format ~ 557
Summary ~ 560

18 Multimedia Programming with Delphi ~ 561
Creating a Simple Media Player ~ 290 (CD)
Using WAV Files in Your Applications ~ 291 (CD)
Playing Video ~ 293 (CD)
Showing the First Frame ~ 294 (CD)
Using the Display Property ~ 294 (CD)
Using the DisplayRect Property ~ 295 (CD)
Understanding TMediaPlayer Events ~ 295 (CD)
Viewing the Source Code for DDGMPlay ~ 296 (CD)
Device Support ~ 298 (CD)
Creating an Audio CD Player ~ 299 (CD)
Displaying a Splash Screen ~ 299 (CD)
Beginning the CD Player ~ 301 (CD)
Updating the CD Player Information ~ 303 (CD)
Methods for Updating the CD Player ~ 305 (CD)
CD Player Source ~ 306 (CD)
Summary ~ 314 (CD)

19 Testing and Debugging ~ 563
Common Program Bugs ~ 317 (CD)
Using a Class Variable Before ItÆs Created ~ 317 (CD)
Ensuring That Class Instances Are Freed ~ 318 (CD)
Taming the Wild Pointer ~ 319 (CD)
Using Uninitialized PChar-Type Variables ~ 320 (CD)
Dereferencing a nil Pointer ~ 320 (CD)
Using the Integrated Debugger ~ 321 (CD)
Using Command-Line Parameters ~ 321 (CD)
Breakpoints ~ 321 (CD)
Executing Code Line by Line ~ 325 (CD)
Using the Watch Window ~ 326 (CD)
Debug Inspectors ~ 326 (CD)
Using the Evaluate and Modify Options ~ 327 (CD)
Accessing the Call Stack ~ 327 (CD)
Viewing Threads ~ 328 (CD)
Event Log ~ 329 (CD)
Modules View ~ 329 (CD)
DLL Debugging ~ 330 (CD)
The CPU View ~ 331 (CD)
Summary ~ 332 (CD)

PART III Component-Based Development ~ 565

20 Key Elements of the VCL and Runtime Type Information ~ 567
What Is a Component? ~ 569
Component Types ~ 569
Standard Components ~ 569
Custom Components ~ 570
Graphical Components ~ 570
Nonvisual Components ~ 571
The Component Structure ~ 571
Properties ~ 571
Types of Properties ~ 573
Methods ~ 574
Events ~ 574
Streamability ~ 576
Ownership ~ 576
Parenthood ~ 577
The Visual Component Hierarchy ~ 578
The TPersistent Class ~ 579
TPersistent Methods ~ 579
The TComponent Class ~ 580
The TControl Class ~ 582
The TWinControl Class ~ 582
The TGraphicControl Class ~ 584
The TCustomControl Class ~ 584
Other Classes ~ 584
Runtime Type Information ~ 587
The TypInfo.pas Unit: Definer of Runtime Type Information ~ 589
Obtaining Type Information ~ 591
Obtaining Type Information on Method Pointers ~ 599
Obtaining Type Information for Ordinal Types ~ 604
Summary ~ 612

21 Writing Delphi Custom Components ~ 613
Component Building Basics ~ 614
Deciding Whether to Write a Component ~ 614
Component Writing Steps ~ 615
Deciding on an Ancestor Class ~ 616
Creating a Component Unit ~ 617
Creating Properties ~ 619
Creating Events ~ 629
Creating Methods ~ 634
Constructors and Destructors ~ 635
Registering Your Component ~ 638
Testing the Component ~ 639
Providing a Component Icon ~ 642
Sample Components ~ 642
Extending Win32 Component Wrapper Capabilities ~ 642
TddgRunButton: Creating Properties ~ 653
TddgButtonEdit - Container Components ~ 660
Design Decisions ~ 660
Surfacing Properties ~ 661
Surfacing Events ~ 661
TddgDigitalClock - Creating Component Events ~ 664
Adding Forms to the Component Palette ~ 668
Component Packages ~ 671
Why Use Packages? ~ 671
Why Not to Use Packages ~ 672
Types of Packages ~ 672
Package Files ~ 673
Package-Enable Your Delphi 5 Applications ~ 673
Installing Packages into DelphiÆs IDE ~ 674
Designing Your Own Packages ~ 674
Package Versioning ~ 680
Package Compiler Directives ~ 680
More on the {$WEAKPACKAGEUNIT} Directive ~ 680
Package-Naming Conventions ~ 681
Add-In Packages ~ 682
Generating Add-In Forms ~ 682
Summary ~ 689

22 Advanced Component Design Techniques ~ 691
Pseudo-Visual Components ~ 692
Extending Hints ~ 692
Creating a THintWindow Descendant ~ 692
An Elliptical Window ~ 695
Enabling the THintWindow Descendant ~ 696
Deploying TDDGHintWindow ~ 696
Animated Components ~ 696
The Marquee Component ~ 696
Writing the Component ~ 697
Drawing on an Offscreen Bitmap ~ 697
Painting the Component ~ 699
Animating the Marquee ~ 700
Testing TddgMarquee ~ 710
Writing Property Editors ~ 713
Creating a Descendant Property Editor Object ~ 714
Editing the Property as Text ~ 715
Registering the New Property Editor ~ 719
Editing the Property as a Whole with a Dialog ~ 721
Component Editors ~ 724
TComponentEditor ~ 725
TDefaultEditor ~ 726
A Simple Component ~ 726
A Simple Component Editor ~ 726
Registering a Component Editor ~ 727
Streaming Nonpublished Component Data ~ 730
Defining Properties ~ 731
An Example of DefineProperty() ~ 732
TddgWaveFile: An Example of DefineBinaryProperty() ~ 734
Property Categories ~ 742
Category Classes ~ 743
Custom Categories ~ 745
Lists of Components: TCollection and TCollectionItem ~ 748
Defining the TCollectionItem Class: TRunBtnItem ~ 750
Defining the TCollection Class: TRunButtons ~ 751
Implementing the TddgLaunchPad, TRunBtnItem,
and TRunButtons Objects ~ 752
Editing the List of TCollectionItem Components with a Dialog Property Editor ~ 760
Summary ~ 772

23 COM-Based Technologies ~ 773
COM Basics ~ 774
COM: The Component Object Model ~ 774
COM Versus ActiveX Versus OLE ~ 775
Terminology ~ 775
WhatÆs So Great About ActiveX? ~ 776
OLE 1 Versus OLE 2 ~ 776
Structured Storage ~ 777
Uniform Data Transfer ~ 777
Threading Models ~ 777
COM+ ~ 778
COM Meets Object Pascal ~ 778
Interfaces ~ 778
The HResult Return Type ~ 786
COM Objects and Class Factories ~ 786
TComObject and TComObjectFactory ~ 787
In-Process COM Servers ~ 788
Out-of-Process COM Servers ~ 791
Aggregation ~ 792
Distributed COM ~ 792
Automation ~ 793
IDispatch ~ 794
Type Information ~ 795
Late Versus Early Binding ~ 795
Registration ~ 796
Creating Automation Servers ~ 796
Creating Automation Controllers ~ 817
Advanced Automation Techniques ~ 825
Automation Events ~ 825
Automation Collections ~ 837
New Interface Types in the Type Library ~ 847
Exchanging Binary Data ~ 848
Behind the Scenes: Language Support for COM ~ 852
Microsoft Transaction Server (MTS) ~ 857
Why MTS? ~ 858
What Is MTS? ~ 858
MTS in Delphi ~ 863
TOleContainer ~ 885
A Small Sample Application ~ 886
A Bigger Sample Application ~ 888
Summary ~ 899

24 Extending the Windows Shell ~ 901
A Tray-Notification Icon Component ~ 902
The API ~ 902
Handling Messages ~ 905
Icons and Hints ~ 905
Mouse Clicks ~ 906
Hiding the Application ~ 908
Sample Tray Application ~ 916
Application Desktop Toolbars ~ 918
The API ~ 918
TAppBar: The AppBar Form ~ 920
Using TAppBar ~ 929
Shell Links ~ 932
Obtaining an IShellLink Instance ~ 934
Using IShellLink ~ 934
A Sample Application ~ 943
Shell Extensions ~ 952
The COM Object Wizard ~ 954
Copy Hook Handlers ~ 954
Context Menu Handlers ~ 960
Icon Handlers ~ 970
Summary ~ 979

25 Creating ActiveX Controls ~ 981
Why Create ActiveX Controls? ~ 982
Creating an ActiveX Control ~ 982
The ActiveX Control Wizard ~ 983
The ActiveX Framework ~ 1014
Property Pages ~ 1017
ActiveForms ~ 1030
Adding Properties to ActiveForms ~ 1030
ActiveX on the Web ~ 1039
Communicating with the Web Browser ~ 1039
Web Deployment ~ 1049
Summary ~ 1053

26 Using DelphiÆs Open Tools API ~ 1055
Open Tools Interfaces ~ 1056
Using the Open Tools API ~ 1058
A Dumb Wizard ~ 1058
The Wizard Wizard ~ 1062
DDG Search ~ 1075
Form Wizards ~ 1086
Summary ~ 1094

27 CORBA Development with Delphi ~ 1095
Object Request Brokers ~ 1096
Interfaces ~ 1096
Stubs and Skeletons ~ 1097
The VisiBroker ORB ~ 1098
VisiBroker Runtime Support Services ~ 1098
VisiBroker Administration Tools ~ 1099
Delphi CORBA Support ~ 1099
CORBA Support Classes ~ 1101
CORBA Object Wizard ~ 1102
The Delphi Type Library Editor ~ 1110
Creating CORBA Solutions with Delphi 5 ~ 1111
Building a CORBA Server ~ 1111
Implementing the Methods of IQueryServer ~ 1113
Building an Early-Bound CORBA Client ~ 1129
Building a Late-Bound CORBA Client ~ 1133
Cross-Language CORBA ~ 1136
Deploying the VisiBroker ORB ~ 1145
Summary ~ 1146

PART IV Database Development ~ 1147

28 Writing Desktop Database Applications ~ 1149
Working with Datasets ~ 1150
VCL Database Architecture ~ 1151
BDE Data-Access Components ~ 1151
Opening a Dataset ~ 1152
Navigating Datasets ~ 1153
TDataSource ~ 1160
Working with Fields ~ 1160
Refreshing the Dataset ~ 1176
Altered States ~ 1177
Filters ~ 1178
Using TTable ~ 1181
Searching for Records ~ 1181
Master/Detail Tables ~ 1184
TTable Events ~ 1186
Creating a Table in Code ~ 1186
Data Modules ~ 1188
The Search, Range, and Filter Demo ~ 1189
The Data Module ~ 1189
The Main Form ~ 1190
The Range Form ~ 1192
The Key Search Form ~ 1194
The Filter Form ~ 1197
TQuery and TStoredProc: The Other Datasets ~ 1200
TQuery ~ 1201
TStoredProc ~ 1201
Text File Tables ~ 1201
The Schema File ~ 1202
The Data File ~ 1204
Using the Text Table ~ 1204
Limitations ~ 1204
Text Table Import ~ 1205
Connecting with ODBC ~ 1206
Where to Find an ODBC Driver ~ 1206
An ODBC Example: Connecting to MS Access ~ 1207
ActiveX Data Objects (ADO) ~ 1211
The WhoÆs Who of Microsoft Data Access ~ 1212
ADOExpress Components ~ 1213
Example: Connecting via ADO ~ 1216
ADO Deployment ~ 1217
Summary ~ 1218

29 Developing Client/Server Applications ~ 1219
Why Client/Server? ~ 1220
Client/Server Architecture ~ 1221
The Client ~ 1221
The Server ~ 1222
Business Rules ~ 1222
Fat Client, Fat Server, or Middle Tier: Where Do Business Rules Belong? ~ 1223
Client/Server Models ~ 1225
The Two-Tiered Model ~ 1226
The Three-Tiered Model ~ 1226
Client/Server Versus Desktop Database Development ~ 1227
Set-Oriented Versus Record-Oriented Data Access ~ 1228
Data Security ~ 1228
Record-Locking Methods ~ 1228
Data Integrity ~ 1229
Transaction Orientation ~ 1230
SQL: Its Role in Client/Server Development ~ 1230
Delphi Client/Server Development ~ 1231
The Server: Designing the Back End ~ 1232
Database Objects ~ 1232
Defining Tables ~ 1233
Using Domains ~ 1235
Defining the Business Rules with Views, Stored Procedures,
and Triggers ~ 1236
Privileges/Access Rights to Database Objects ~ 1243
The Client: Designing the Front End ~ 1245
Using the TDatabase Component ~ 1245
TTable or TQuery ~ 1255
Using the TQuery Component ~ 1257
Executing Stored Procedures ~ 1265
Summary ~ 1269

30 Extending Database VCL ~ 1271
Using the BDE ~ 334 (CD)
The BDE Unit ~ 334 (CD)
Check() ~ 334 (CD)
Cursors and Handles ~ 335 (CD)
Synching Cursors ~ 335 (CD)
dBASE Tables ~ 336 (CD)
Physical Record Number ~ 336 (CD)
Viewing Deleted Records ~ 337 (CD)
Testing for a Deleted Record ~ 339 (CD)
Undeleting a Record ~ 339 (CD)
Packing a Table ~ 340 (CD)
Paradox Tables ~ 341 (CD)
Sequence Number ~ 341 (CD)
Table Packing ~ 341 (CD)
Limiting TQuery Result Sets ~ 348 (CD)
BDE Miscellany ~ 350 (CD)
Writing Data-Aware VCL Controls ~ 355 (CD)
Extending TDataSet ~ 359 (CD)
In the Olden Daysà ~ 359 (CD)
Modern Times ~ 360 (CD)
Creating a TDataSet Descendant ~ 361 (CD)
Summary ~ 387 (CD)

31 Internet-Enabling Your Applications with WebBroker ~ 1273
ISAPI, NSAPI, and CGI Web Server Extensions ~ 1275
The Common Gateway Interface ~ 1275
ISAPI and NSAPI ~ 1276
Creating Web Applications with Delphi ~ 1277
TWebModule and TWebDispatcher ~ 1277
TWebRequest and TWebResponse ~ 1281
Dynamic HTML Pages with HTML Content Producers ~ 1285
TPageProducer ~ 1285
TDataSetTableProducer and TQueryTableProducer ~ 1288
Maintaining State with Cookies ~ 1295
Redirecting to a Different Web Site ~ 1300
Retrieving Information from HTML Forms ~ 1301
Data Streaming ~ 1303
Summary ~ 1307

32 Midas Development ~ 1309
Mechanics of Creating a Multitier Application ~ 1310
Benefits of the Multitier Architecture ~ 1311
Centralized Business Logic ~ 1311
Thin-Client Architecture ~ 1311
Automatic Error Reconciliation ~ 1312
Briefcase Model ~ 1312
Fault Tolerance ~ 1312
Load Balancing ~ 1312
Classic Mistakes ~ 1313
Typical MIDAS Architecture ~ 1313
Server ~ 1314
Client ~ 1317
Using MIDAS to Create an Application ~ 1319
Setting Up the Server ~ 1319
Retrieving Data ~ 1321
More Options to Make Your Application Robust ~ 1327
Client Optimization Techniques ~ 1327
Application Server Techniques ~ 1330
Real-World Examples ~ 1332
More Client Dataset Features ~ 1343
Deploying MIDAS Applications ~ 1353
Licensing Issues ~ 1353
DCOM Configuration ~ 1354
Files to Deploy ~ 1355
Internet Deployment Considerations (Firewalls) ~ 1356
Summary ~ 1358

PART V Rapid Database Application Development ~ 1359

33 Inventory Manager: Client/Server Development ~ 1361
Designing the Back End ~ 1362
Defining Domains ~ 1364
Defining the Tables ~ 1365
Defining Generators ~ 1367
Defining Triggers ~ 1367
Defining Stored Procedures ~ 1368
Granting Permissions ~ 1371
Centralizing Database Access: The Business Rules ~ 1371
Login/Logout Methods ~ 1383
Customer Table Methods ~ 1385
Part Table Methods ~ 1385
Sales Methods ~ 1385
Temporary Table Methods ~ 1386
Designing the User Interface ~ 1388
TMainForm: The ApplicationÆs Main Form ~ 1388
TCustomerForm: Customer Entry ~ 1394
TPartsForm: Inventory Entry ~ 1398
TSalesForm: Sales Browsing ~ 1403
TNewSalesForm: Sales Entry ~ 1404
The CustomerSearch Dialog ~ 1408
Summary ~ 1414

34 Client Tracker: MIDAS Development ~ 1415
Designing the Server Application ~ 1416
Designing the Client Application ~ 1419
Client Data Module ~ 1419
Client Main Form ~ 1430
Summary ~ 1437

35 DDG Bug-Reporting Tool: Desktop Application Development ~ 1439
General Application Requirements ~ 1440
World Wide WebûReady ~ 1440
User Data Entry and Logon ~ 1440
Bug Manipulation, Browsing, and Filtering ~ 1440
Bug Actions ~ 1441
Other UI Functionality ~ 1441
The Data Model ~ 1441
Developing the Data Module ~ 1441
Application Initialization and Login ~ 1453
Generating Paradox Keys ~ 1454
Bug-Manipulation Routines ~ 1455
Browsing/Filtering Bugs ~ 1455
Adding Users ~ 1455
Adding Actions ~ 1457
Developing the User Interface ~ 1459
The Main Form ~ 1459
Other User Interface Issues ~ 1467
Enabling the Application for the Web ~ 1467
Summary ~ 1467

36 DDG Bug-Reporting Tool: Using WebBroker ~ 1469
The Page Layout ~ 1470
Changes to the Data Module ~ 1471
Setting Up the TDataSetTableProducer Component: dstpBugs ~ 1471
Setting Up the TWebDispatcher Component: wbdpBugs ~ 1472
Setting Up the TPageProducer Component: pprdBugs ~ 1473
Coding the DDGWebBugs ISAPI Server: Adding TActionItem Instances ~ 1473
Helper Routines ~ 1473
The Introduction Page ~ 1474
Obtaining and Verifying the User Login Name ~ 1476
Browsing Bugs ~ 1480
Browsing All Bugs ~ 1480
Browsing User-Entered Bugs ~ 1482
Formatting Table Cells and Displaying Bug Detail ~ 1484
Adding a New Bug ~ 1486
Retrieving the Bug Data ~ 1486
Verifying Bug Insertion ~ 1488
Summary ~ 1491

PART VI Appendixes ~ 1493

A Error Messages and Exceptions ~ 1495
Layers of Handlers, Layers of Severity ~ 390 (CD)
Runtime Errors ~ 391 (CD)
Exceptions ~ 391 (CD)
Win32 System Errors ~ 397 (CD)
B BDE Error Codes ~ 1497
C Suggested Reading ~ 1499
Delphi Programming ~ 1500
Component Design ~ 1500
Windows Programming ~ 1500
Object-Oriented Programming ~ 1500
Software Project Management and User Interface Design ~ 1500
COM/ActiveX/OLE ~ 1501
Index ~ 1503