Developers Guide Delphi 6 For Windows download
Developers Guide Delphi 6 For Windows download
https://ebookbell.com/product/developers-guide-delphi-6-for-
windows-1021628
https://ebookbell.com/product/delphi-6-for-windows-developers-guide-
borland-6760192
https://ebookbell.com/product/borland-delphi-6-developers-guide-steve-
teixeira-xavier-pacheco-6760318
https://ebookbell.com/product/developers-guide-borland-delphi-7-for-
windows-borland-software-corporation-36903922
https://ebookbell.com/product/the-tomes-of-delphi-developers-guide-to-
troubleshooting-wordware-delphi-developers-library-clay-
shannon-1474192
Delphi Developers Guide To Xml Keith Wood
https://ebookbell.com/product/delphi-developers-guide-to-xml-keith-
wood-984346
https://ebookbell.com/product/delphi-for-net-developers-guide-xavier-
pacheco-5903518
https://ebookbell.com/product/delphi-7-for-windows-developers-guide-
borland-6773342
https://ebookbell.com/product/developers-guide-to-microsoft-
prism-4-building-modular-mvvm-applications-with-windows-presentation-
foundation-and-microsoft-silverlight-1st-edition-bob-brumfield-2120280
https://ebookbell.com/product/developers-guide-to-multiplayer-games-
wordware-game-developers-library-andrew-mulholland-2140102
Developer’s Guide
Borland®
™
Delphi 6
for Windows
Borland Software Corporation
100 Enterprise Way, Scotts Valley, CA 95066-3249
Refer to the DEPLOY document located in the root directory of your Delphi 6 product for a complete list of files that
you can distribute in accordance with the Delphi 6 License Statement and Limited Warranty.
Inprise may have patents and/or pending patent applications covering subject matter in this document. The
furnishing of this document does not give you any license to these patents.
COPYRIGHT © 1983, 2001 Borland Software Corporation. All rights reserved. All Borland brand and product names
are trademarks or registered trademarks of Borland Software Corporation. Other brand and product names are
trademarks or registered trademarks of their respective holders.
Printed in the U.S.A.
HDE1350WW21001 1E0R0501
0102030405-9 8 7 6 5 4 3 2 1
D3
Contents
Chapter 1 TPersistent branch. . . . . . . . . . . . . . . 3-14
TComponent branch . . . . . . . . . . . . . 3-15
Introduction 1-1 TControl branch . . . . . . . . . . . . . . . . 3-16
What’s in this manual? . . . . . . . . . . . . . . 1-1
TWinControl/TWidgetControl branch . . . 3-17
Manual conventions . . . . . . . . . . . . . . . . 1-3
Properties common to TControl . . . . . . . 3-18
Developer support services . . . . . . . . . . . . 1-3
Action properties . . . . . . . . . . . . . 3-18
Ordering printed documentation . . . . . . . . 1-3
Position, size, and alignment
Part I properties . . . . . . . . . . . . . . . . . 3-19
Display properties . . . . . . . . . . . . . 3-19
Programming with Delphi Parent properties. . . . . . . . . . . . . . 3-19
A navigation property. . . . . . . . . . . 3-19
Chapter 2 Drag-and-drop properties . . . . . . . . 3-20
Developing applications with Delphi 2-1 Drag-and-dock properties
Integrated development environment . . . . . . 2-1 (VCL only) . . . . . . . . . . . . . . . . 3-20
Designing applications . . . . . . . . . . . . . . 2-2 Standard events common to TControl . . . 3-20
Developing applications . . . . . . . . . . . . . 2-3 Properties common to TWinControl and
Creating projects . . . . . . . . . . . . . . . . 2-3 TWidgetControl . . . . . . . . . . . . . . . 3-21
Editing code. . . . . . . . . . . . . . . . . . . 2-4 General information properties . . . . . 3-21
Compiling applications . . . . . . . . . . . . 2-4 Border style display properties. . . . . . 3-22
Debugging applications . . . . . . . . . . . . 2-5 Navigation properties . . . . . . . . . . . 3-22
Deploying applications . . . . . . . . . . . . 2-5 Drag-and-dock properties
(VCL only) . . . . . . . . . . . . . . . . 3-22
Chapter 3 Events common to TWinControl and
Using the component libraries 3-1 TWidgetControl . . . . . . . . . . . . . . . 3-22
Understanding the component libraries. . . . . 3-1 Creating the application user interface . . . 3-23
Properties, methods, and events . . . . . . . 3-2 Using Delphi components . . . . . . . . . . 3-23
Properties . . . . . . . . . . . . . . . . . . 3-2 Setting component properties . . . . . . . . 3-24
Methods . . . . . . . . . . . . . . . . . . . 3-3 Using the Object Inspector . . . . . . . . 3-24
Events . . . . . . . . . . . . . . . . . . . . 3-3 Using property editors . . . . . . . . . . 3-25
User events . . . . . . . . . . . . . . . . . 3-3 Setting properties at runtime . . . . . . . 3-25
System events . . . . . . . . . . . . . . . . 3-4 Calling methods . . . . . . . . . . . . . . . . 3-25
Object Pascal and the class libraries . . . . . . . 3-4 Working with events and event
Using the object model . . . . . . . . . . . . 3-4 handlers. . . . . . . . . . . . . . . . . . . . 3-25
What is an object?. . . . . . . . . . . . . . 3-5 Generating a new event handler . . . . . 3-26
Examining a Delphi object . . . . . . . . . 3-5 Generating a handler for a component’s
Changing the name of a component . . . 3-7 default event . . . . . . . . . . . . . . . 3-26
Inheriting data and code from an object . . . 3-8 Locating event handlers. . . . . . . . . . 3-26
Scope and qualifiers . . . . . . . . . . . . . . 3-8 Associating an event with an existing
Private, protected, public, and published event handler . . . . . . . . . . . . . . . 3-27
declarations . . . . . . . . . . . . . . . . 3-9 Associating menu events with event
Using object variables . . . . . . . . . . . . . 3-10 handlers . . . . . . . . . . . . . . . . . . 3-28
Creating, instantiating, and destroying Deleting event handlers . . . . . . . . . . 3-28
objects . . . . . . . . . . . . . . . . . . . . . 3-11 VCL and CLX components . . . . . . . . . . . 3-28
Components and ownership . . . . . . . . . 3-11 Adding custom components to the
Objects, components, and controls . . . . . . . . 3-12 Component palette . . . . . . . . . . . . . 3-30
TObject branch . . . . . . . . . . . . . . . . . 3-14 Text controls . . . . . . . . . . . . . . . . . . 3-31
Text control properties. . . . . . . . . . . 3-31
iii
Properties of memo and rich text Using helper objects . . . . . . . . . . . . . . . 3-46
controls . . . . . . . . . . . . . . . . . . . 3-31 Working with lists . . . . . . . . . . . . . . . 3-47
Rich text controls (VCL only) . . . . . . . 3-32 Working with string lists . . . . . . . . . . . 3-47
Specialized input controls . . . . . . . . . . . 3-32 Loading and saving string lists. . . . . . 3-48
Scroll bars . . . . . . . . . . . . . . . . . . 3-32 Creating a new string list . . . . . . . . . 3-48
Track bars . . . . . . . . . . . . . . . . . . 3-33 Manipulating strings in a list . . . . . . . 3-50
Up-down controls (VCL only). . . . . . . 3-33 Associating objects with a string list. . . 3-52
Spin edit controls (CLX only) . . . . . . . 3-33 Windows registry and INI files . . . . . . . 3-52
Hot key controls (VCL only). . . . . . . . 3-33 Using TIniFile (VCL only) . . . . . . . . 3-52
Splitter controls . . . . . . . . . . . . . . . 3-34 Using TRegistry . . . . . . . . . . . . . . 3-53
Buttons and similar controls . . . . . . . . . 3-34 Using TRegIniFile . . . . . . . . . . . . . 3-53
Button controls . . . . . . . . . . . . . . . 3-34 Creating drawing spaces . . . . . . . . . . . 3-54
Bitmap buttons . . . . . . . . . . . . . . . 3-35 Printing . . . . . . . . . . . . . . . . . . . . . 3-54
Speed buttons . . . . . . . . . . . . . . . . 3-35 Using streams . . . . . . . . . . . . . . . . . 3-55
Check boxes . . . . . . . . . . . . . . . . . 3-35
Radio buttons . . . . . . . . . . . . . . . . 3-35 Chapter 4
Toolbars . . . . . . . . . . . . . . . . . . . 3-36 Common programming tasks 4-1
Cool bars (VCL only) . . . . . . . . . . . . 3-36 Understanding classes . . . . . . . . . . . . . . . 4-1
Handling lists . . . . . . . . . . . . . . . . . . 3-36 Defining classes . . . . . . . . . . . . . . . . . . . 4-2
List boxes and check-list boxes . . . . . . 3-37 Handling exceptions . . . . . . . . . . . . . . . . 4-4
Combo boxes . . . . . . . . . . . . . . . . 3-37 Protecting blocks of code . . . . . . . . . . . . 4-4
Tree views . . . . . . . . . . . . . . . . . . 3-38 Responding to exceptions. . . . . . . . . . 4-5
List views . . . . . . . . . . . . . . . . . . 3-38 Exceptions and the flow of control. . . . . 4-6
Date-time pickers and month Nesting exception responses . . . . . . . . 4-6
calendars (VCL only) . . . . . . . . . . . 3-39 Protecting resource allocations. . . . . . . . . 4-7
Grouping components . . . . . . . . . . . . . 3-39 What kind of resources need
Group boxes and radio groups . . . . . . 3-39 protection? . . . . . . . . . . . . . . . . . 4-7
Panels . . . . . . . . . . . . . . . . . . . . 3-39 Creating a resource protection block. . . . 4-8
Scroll boxes . . . . . . . . . . . . . . . . . 3-40 Handling RTL exceptions. . . . . . . . . . . . 4-9
Tab controls . . . . . . . . . . . . . . . . . 3-40 What are RTL exceptions? . . . . . . . . . 4-9
Page controls . . . . . . . . . . . . . . . . 3-40 Creating an exception handler . . . . . . 4-10
Header controls . . . . . . . . . . . . . . . 3-41 Exception handling statements. . . . . . 4-11
Providing visual feedback . . . . . . . . . . . 3-41 Using the exception instance . . . . . . . 4-11
Labels and static text components . . . . 3-41 Scope of exception handlers . . . . . . . 4-12
Status bars . . . . . . . . . . . . . . . . . . 3-42 Providing default exception
Progress bars . . . . . . . . . . . . . . . . 3-42 handlers . . . . . . . . . . . . . . . . . . 4-12
Help and hint properties . . . . . . . . . . 3-42 Handling classes of exceptions . . . . . . 4-13
Grids . . . . . . . . . . . . . . . . . . . . . . . 3-43 Reraising the exception . . . . . . . . . . 4-13
Draw grids. . . . . . . . . . . . . . . . . . 3-43 Handling component exceptions . . . . . . 4-14
String grids . . . . . . . . . . . . . . . . . 3-43 Exception handling with external
Value list editors (VCL only) . . . . . . . . . 3-43 sources . . . . . . . . . . . . . . . . . . . . 4-15
Displaying graphics . . . . . . . . . . . . . . 3-44 Silent exceptions. . . . . . . . . . . . . . . . 4-15
Images . . . . . . . . . . . . . . . . . . . . 3-44 Defining your own exceptions . . . . . . . . 4-16
Shapes . . . . . . . . . . . . . . . . . . . . 3-44 Declaring an exception object type. . . . 4-16
Bevels . . . . . . . . . . . . . . . . . . . . 3-45 Raising an exception. . . . . . . . . . . . 4-17
Paint boxes. . . . . . . . . . . . . . . . . . 3-45 Using interfaces . . . . . . . . . . . . . . . . . . 4-17
Animation control (VCL only). . . . . . . 3-45 Interfaces as a language feature . . . . . . . 4-18
Developing dialog boxes . . . . . . . . . . . 3-45 Implementing interfaces across
Using open dialog boxes . . . . . . . . . . 3-46 the hierarchy . . . . . . . . . . . . . . . 4-18
iv
Using interfaces with procedures . . . . . 4-20 Passing a local variable as a PChar . . . 4-48
Implementing IInterface . . . . . . . . . . . . 4-20 Compiler directives for strings. . . . . . . . 4-49
TInterfacedObject . . . . . . . . . . . . . . . 4-21 Strings and characters: related topics . . . . 4-50
Using the as operator . . . . . . . . . . . . . 4-21 Working with files . . . . . . . . . . . . . . . . 4-50
Reusing code and delegation . . . . . . . . . 4-22 Manipulating files . . . . . . . . . . . . . . . 4-50
Using implements for delegation . . . . . 4-22 Deleting a file. . . . . . . . . . . . . . . . 4-50
Aggregation . . . . . . . . . . . . . . . . . 4-23 Finding a file . . . . . . . . . . . . . . . . 4-51
Memory management of interface Renaming a file. . . . . . . . . . . . . . . 4-52
objects . . . . . . . . . . . . . . . . . . . . . 4-24 File date-time routines . . . . . . . . . . 4-52
Using reference counting . . . . . . . . . 4-24 Copying a file . . . . . . . . . . . . . . . 4-53
Not using reference counting . . . . . . . 4-25 File types with file I/O . . . . . . . . . . . . 4-53
Using interfaces in distributed Using file streams . . . . . . . . . . . . . . . 4-54
applications (VCL only) . . . . . . . . . . . 4-26 Creating and opening files . . . . . . . . 4-54
Defining custom variants . . . . . . . . . . . . . 4-27 Using the file handle . . . . . . . . . . . 4-55
Storing a custom variant type’s data . . . . . 4-28 Reading and writing to files . . . . . . . 4-55
Creating a class to enable the custom Reading and writing strings . . . . . . . 4-56
variant type . . . . . . . . . . . . . . . . . . 4-28 Seeking a file . . . . . . . . . . . . . . . . 4-56
Enabling casting . . . . . . . . . . . . . . 4-29 File position and size . . . . . . . . . . . 4-57
Implementing binary operations . . . . . 4-30 Copying . . . . . . . . . . . . . . . . . . . 4-57
Implementing comparison operations . . 4-32 Converting measurements . . . . . . . . . . . . 4-58
Implementing unary operations . . . . . 4-34 Performing conversions . . . . . . . . . . . 4-58
Copying and clearing custom Performing simple conversions . . . . . 4-58
variants. . . . . . . . . . . . . . . . . . . 4-34 Performing complex conversions . . . . 4-58
Loading and saving custom variant Adding new measurement types . . . . . . 4-59
values. . . . . . . . . . . . . . . . . . . . 4-35 Creating a simple conversion family
Using the TCustomVariantType and adding units . . . . . . . . . . . . . 4-59
descendant . . . . . . . . . . . . . . . . . 4-36 Using a conversion function . . . . . . . 4-60
Writing utilities to work with a custom Using a class to manage
variant type . . . . . . . . . . . . . . . . . . 4-36 conversions . . . . . . . . . . . . . . . . 4-62
Supporting properties and methods in Defining data types . . . . . . . . . . . . . . . . 4-64
custom variants . . . . . . . . . . . . . . . . 4-37
Using TInvokeableVariantType . . . . . . 4-37 Chapter 5
Using TPublishableVariantType. . . . . . 4-39 Building applications, components,
Working with strings . . . . . . . . . . . . . . . 4-39
Character types . . . . . . . . . . . . . . . . . 4-39
and libraries 5-1
Creating applications . . . . . . . . . . . . . . . . 5-1
String types . . . . . . . . . . . . . . . . . . . 4-40
GUI applications. . . . . . . . . . . . . . . . . 5-1
Short strings . . . . . . . . . . . . . . . . . 4-40
User interface models . . . . . . . . . . . . 5-2
Long strings . . . . . . . . . . . . . . . . . 4-41
SDI applications . . . . . . . . . . . . . . . 5-2
WideString. . . . . . . . . . . . . . . . . . 4-41
MDI applications. . . . . . . . . . . . . . . 5-2
PChar types . . . . . . . . . . . . . . . . . 4-42
Setting IDE, project, and compilation
OpenString . . . . . . . . . . . . . . . . . 4-42
options . . . . . . . . . . . . . . . . . . . 5-3
Runtime library string handling routines . . 4-42
Programming templates . . . . . . . . . . . . 5-3
Wide character routines . . . . . . . . . . 4-43
Console applications . . . . . . . . . . . . . . 5-3
Commonly used long string routines. . . 4-43
Service applications . . . . . . . . . . . . . . . 5-4
Declaring and initializing strings . . . . . . . 4-46
Service threads . . . . . . . . . . . . . . . . 5-6
Mixing and converting string types . . . . . 4-47
Service name properties. . . . . . . . . . . 5-7
String to PChar conversions. . . . . . . . . . 4-47
Debugging services . . . . . . . . . . . . . 5-8
String dependencies . . . . . . . . . . . . 4-47
Creating packages and DLLs . . . . . . . . . . . 5-9
Returning a PChar local variable . . . . . 4-48
When to use packages and DLLs . . . . . . . 5-9
v
Writing database applications . . . . . . . . . . 5-10 Registering Help selectors . . . . . . . . 5-27
Distributing database applications . . . . . . 5-11 Using Help in a VCL Application . . . . . . . . 5-28
Creating Web server applications . . . . . . . . 5-11 How TApplication processes VCL
Using Web Broker . . . . . . . . . . . . . . . 5-11 Help . . . . . . . . . . . . . . . . . . . . . . 5-28
Creating WebSnap applications. . . . . . . . 5-13 How VCL controls process Help. . . . . . . 5-28
Using InternetExpress . . . . . . . . . . . . . 5-13 Using Help in a CLX Application . . . . . . . . 5-29
Creating Web Services applications . . . . . 5-13 How TApplication processes CLX
Writing applications using COM. . . . . . . . . 5-14 Help . . . . . . . . . . . . . . . . . . . . . . 5-29
Using COM and DCOM . . . . . . . . . . . . 5-14 How CLX controls process Help. . . . . . . 5-29
Using MTS and COM+ . . . . . . . . . . . . 5-14 Calling a Help system directly . . . . . . . . . 5-30
Using data modules . . . . . . . . . . . . . . . . 5-15 Using IHelpSystem . . . . . . . . . . . . . . . . 5-30
Creating and editing standard data Customizing the IDE Help system . . . . . . . 5-30
modules . . . . . . . . . . . . . . . . . . . . 5-15
Naming a data module and its unit Chapter 6
file. . . . . . . . . . . . . . . . . . . . . . 5-16 Developing the application user
Placing and naming components . . . . . 5-17
Using component properties and
interface 6-1
Controlling application behavior . . . . . . . . . 6-1
events in a data module . . . . . . . . . 5-17
Using the main form . . . . . . . . . . . . . . 6-1
Creating business rules in a data
Adding forms . . . . . . . . . . . . . . . . . . 6-2
module . . . . . . . . . . . . . . . . . . . 5-18
Linking forms . . . . . . . . . . . . . . . . 6-2
Accessing a data module from a form . . . . 5-18
Avoiding circular unit references. . . . . . 6-2
Adding a remote data module to an
Hiding the main form. . . . . . . . . . . . . . 6-3
application server project . . . . . . . . . . 5-19
Working at the application level . . . . . . . . 6-3
Using the Object Repository . . . . . . . . . . . 5-19
Handling the screen . . . . . . . . . . . . . . . 6-3
Sharing items within a project . . . . . . . . 5-19
Managing layout . . . . . . . . . . . . . . . . 6-4
Adding items to the Object Repository . . . 5-19
Responding to event notification . . . . . . . . . 6-5
Sharing objects in a team environment . . . 5-20
Using forms . . . . . . . . . . . . . . . . . . . . . 6-5
Using an Object Repository item in
Controlling when forms reside in
a project . . . . . . . . . . . . . . . . . . . . 5-20
memory . . . . . . . . . . . . . . . . . . . . . 6-6
Copying an item . . . . . . . . . . . . . . 5-20
Displaying an auto-created form. . . . . . 6-6
Inheriting an item. . . . . . . . . . . . . . 5-20
Creating forms dynamically . . . . . . . . 6-6
Using an item . . . . . . . . . . . . . . . . 5-21
Creating modeless forms such as
Using project templates . . . . . . . . . . . . 5-21
windows . . . . . . . . . . . . . . . . . . 6-7
Modifying shared items . . . . . . . . . . . . 5-21
Using a local variable to create a form
Specifying a default project, new form,
instance . . . . . . . . . . . . . . . . . . . 6-7
and main form . . . . . . . . . . . . . . . . 5-21
Passing additional arguments to forms . . . . 6-8
Enabling Help in applications . . . . . . . . . . 5-22
Retrieving data from forms. . . . . . . . . . . 6-9
Help system interfaces . . . . . . . . . . . . . 5-22
Retrieving data from modeless forms . . . 6-9
Implementing ICustomHelpViewer . . . . . 5-23
Retrieving data from modal forms. . . . 6-10
Communicating with the Help
Reusing components and groups of
Manager . . . . . . . . . . . . . . . . . . . . 5-23
components . . . . . . . . . . . . . . . . . . . 6-12
Asking the Help Manager for
Creating and using component templates . . . 6-13
information . . . . . . . . . . . . . . . . . . 5-24
Working with frames . . . . . . . . . . . . . . . 6-13
Displaying keyword-based Help . . . . . . . 5-24
Creating frames . . . . . . . . . . . . . . . . 6-14
Displaying tables of contents . . . . . . . . . 5-25
Adding frames to the component
Implementing IExtendedHelpViewer . . . . 5-26
palette . . . . . . . . . . . . . . . . . . . . . 6-14
Implementing IHelpSelector . . . . . . . . . 5-26
Using and modifying frames. . . . . . . . . 6-14
Registering Help system objects . . . . . . . 5-27
Sharing frames. . . . . . . . . . . . . . . . . 6-15
Registering Help viewers . . . . . . . . . 5-27
vi
Organizing actions for toolbars and Merging menus . . . . . . . . . . . . . . . . 6-40
menus . . . . . . . . . . . . . . . . . . . . . . . 6-16 Specifying the active menu: Menu
What is an action? . . . . . . . . . . . . . . . 6-17 property . . . . . . . . . . . . . . . . . . 6-40
Setting up action bands . . . . . . . . . . . . 6-18 Determining the order of merged menu
Creating toolbars and menus . . . . . . . . . 6-18 items: GroupIndex property . . . . . . 6-40
Adding color, patterns, or pictures to Importing resource files . . . . . . . . . . . 6-41
menus, buttons, and toolbars . . . . . . 6-20 Designing toolbars and cool bars . . . . . . . . 6-41
Adding icons to menus and toolbars . . . 6-21 Adding a toolbar using a panel
Creating toolbars and menus that component . . . . . . . . . . . . . . . . . . 6-42
users can customize. . . . . . . . . . . . 6-21 Adding a speed button to a panel . . . . 6-43
Hiding unused items and categories Assigning a speed button’s glyph . . . . 6-43
in action bands . . . . . . . . . . . . . . 6-22 Setting the initial condition of a
Using action lists . . . . . . . . . . . . . . . . . . 6-23 speed button . . . . . . . . . . . . . . . 6-43
Setting up action lists . . . . . . . . . . . . . 6-23 Creating a group of speed buttons . . . . 6-44
What happens when an action fires . . . . . 6-24 Allowing toggle buttons . . . . . . . . . 6-44
Responding with events . . . . . . . . . . 6-24 Adding a toolbar using the toolbar
How actions find their targets . . . . . . . 6-26 component . . . . . . . . . . . . . . . . . . 6-44
Updating actions . . . . . . . . . . . . . . . . 6-26 Adding a tool button . . . . . . . . . . . 6-45
Predefined action classes . . . . . . . . . . . 6-26 Assigning images to tool buttons . . . . 6-45
Writing action components . . . . . . . . . . 6-27 Setting tool button appearance and
Registering actions . . . . . . . . . . . . . . . 6-28 initial conditions . . . . . . . . . . . . . 6-46
Creating and managing menus. . . . . . . . . . 6-29 Creating groups of tool buttons . . . . . 6-46
Opening the Menu Designer . . . . . . . . . 6-29 Allowing toggled tool buttons . . . . . . 6-46
Building menus . . . . . . . . . . . . . . . . . 6-31 Adding a cool bar component . . . . . . . . 6-47
Naming menus . . . . . . . . . . . . . . . 6-31 Setting the appearance of the
Naming the menu items . . . . . . . . . . 6-31 cool bar . . . . . . . . . . . . . . . . . . 6-47
Adding, inserting, and deleting Responding to clicks . . . . . . . . . . . . . 6-48
menu items . . . . . . . . . . . . . . . . 6-32 Assigning a menu to a tool button . . . . 6-48
Adding separator bars . . . . . . . . . . . 6-32 Adding hidden toolbars . . . . . . . . . . . 6-48
Specifying accelerator keys and Hiding and showing toolbars . . . . . . . . 6-48
keyboard shortcuts . . . . . . . . . . . . 6-33 Demo programs . . . . . . . . . . . . . . . . 6-49
Creating submenus. . . . . . . . . . . . . . . 6-33
Creating submenus by demoting Chapter 7
existing menus . . . . . . . . . . . . . . 6-34 Working with controls 7-1
Moving menu items . . . . . . . . . . . . 6-34 Implementing drag-and-drop in controls . . . . 7-1
Adding images to menu items . . . . . . 6-35 Starting a drag operation . . . . . . . . . . . . 7-1
Viewing the menu . . . . . . . . . . . . . 6-35 Accepting dragged items . . . . . . . . . . . . 7-2
Editing menu items in the Object Dropping items . . . . . . . . . . . . . . . . . 7-2
Inspector . . . . . . . . . . . . . . . . . . . . 6-35 Ending a drag operation . . . . . . . . . . . . 7-3
Using the Menu Designer context Customizing drag and drop with a
menu . . . . . . . . . . . . . . . . . . . . . . 6-36 drag object . . . . . . . . . . . . . . . . . . . 7-3
Commands on the context menu . . . . . 6-36 Changing the drag mouse pointer. . . . . . . 7-4
Switching between menus at design Implementing drag-and-dock in controls . . . . 7-4
time . . . . . . . . . . . . . . . . . . . . . 6-37 Making a windowed control a docking
Using menu templates . . . . . . . . . . . . . 6-37 site. . . . . . . . . . . . . . . . . . . . . . . . 7-4
Saving a menu as a template . . . . . . . . . 6-38 Making a control a dockable child. . . . . . . 7-4
Naming conventions for template Controlling how child controls are
menu items and event handlers . . . . . 6-39 docked . . . . . . . . . . . . . . . . . . . . . 7-5
Manipulating menu items at runtime . . . . 6-40
vii
Controlling how child controls are Making scrollable graphics . . . . . . . . 8-16
undocked . . . . . . . . . . . . . . . . . . . 7-6 Adding an image control . . . . . . . . . 8-17
Controlling how child controls respond Loading and saving graphics files . . . . . . 8-18
to drag-and-dock operations . . . . . . . . 7-6 Loading a picture from a file . . . . . . . 8-19
Working with text in controls. . . . . . . . . . . 7-6 Saving a picture to a file. . . . . . . . . . 8-19
Setting text alignment . . . . . . . . . . . . . 7-7 Replacing the picture . . . . . . . . . . . 8-20
Adding scroll bars at runtime . . . . . . . . . 7-7 Using the clipboard with graphics . . . . . 8-21
Adding the clipboard object. . . . . . . . . . 7-8 Copying graphics to the clipboard. . . . 8-21
Selecting text . . . . . . . . . . . . . . . . . . 7-8 Cutting graphics to the clipboard . . . . 8-21
Selecting all text . . . . . . . . . . . . . . . . 7-9 Pasting graphics from the clipboard . . . 8-22
Cutting, copying, and pasting text . . . . . . 7-9 Rubber banding example . . . . . . . . . . . 8-23
Deleting selected text . . . . . . . . . . . . . 7-9 Responding to the mouse . . . . . . . . . 8-23
Disabling menu items . . . . . . . . . . . . . 7-10 Responding to a mouse-down action . . 8-24
Providing a pop-up menu . . . . . . . . . . . 7-10 Adding a field to a form object to track
Handling the OnPopup event. . . . . . . . . 7-11 mouse actions . . . . . . . . . . . . . . 8-26
Adding graphics to controls . . . . . . . . . . . 7-11 Refining line drawing . . . . . . . . . . . 8-27
Indicating that a control is Working with multimedia . . . . . . . . . . . . 8-28
owner-drawn . . . . . . . . . . . . . . . . . 7-12 Adding silent video clips to an
Adding graphical objects to a string list . . . 7-12 application . . . . . . . . . . . . . . . . . . 8-29
Adding images to an application . . . . . 7-13 Example of adding silent video clips . . 8-30
Adding images to a string list . . . . . . . 7-13 Adding audio and/or video clips to an
Drawing owner-drawn items . . . . . . . 7-13 application . . . . . . . . . . . . . . . . . . 8-30
Sizing owner-draw items . . . . . . . . . . . 7-14 Example of adding audio and/or video
Drawing owner-draw items. . . . . . . . . . 7-15 clips (VCL only) . . . . . . . . . . . . . 8-32
Chapter 8 Chapter 9
Working with graphics and Writing multi-threaded applications 9-1
multimedia 8-1 Defining thread objects . . . . . . . . . . . . . . . 9-1
Overview of graphics programming. . . . . . . 8-1 Initializing the thread . . . . . . . . . . . . . . 9-2
Refreshing the screen . . . . . . . . . . . . . 8-2 Assigning a default priority . . . . . . . . 9-2
Types of graphic objects . . . . . . . . . . . . 8-3 Indicating when threads are freed . . . . . 9-3
Common properties and methods of Writing the thread function . . . . . . . . . . 9-4
Canvas . . . . . . . . . . . . . . . . . . . . . 8-4 Using the main VCL/CLX thread . . . . . 9-4
Using the properties of the Canvas Using thread-local variables . . . . . . . . 9-5
object . . . . . . . . . . . . . . . . . . . . . 8-5 Checking for termination by other
Using pens. . . . . . . . . . . . . . . . . . 8-5 threads . . . . . . . . . . . . . . . . . . . 9-5
Using brushes . . . . . . . . . . . . . . . . 8-8 Handling exceptions in the thread
Reading and setting pixels . . . . . . . . . 8-9 function . . . . . . . . . . . . . . . . . . . 9-6
Using Canvas methods to draw graphic Writing clean-up code. . . . . . . . . . . . . . 9-6
objects . . . . . . . . . . . . . . . . . . . . . 8-9 Coordinating threads . . . . . . . . . . . . . . . . 9-7
Drawing lines and polylines. . . . . . . . 8-10 Avoiding simultaneous access . . . . . . . . . 9-7
Drawing shapes . . . . . . . . . . . . . . . 8-11 Locking objects. . . . . . . . . . . . . . . . 9-7
Handling multiple drawing objects in Using critical sections . . . . . . . . . . . . 9-7
your application . . . . . . . . . . . . . . . 8-12 Using the multi-read exclusive-write
Keeping track of which drawing tool synchronizer . . . . . . . . . . . . . . . . 9-8
to use . . . . . . . . . . . . . . . . . . . . 8-12 Other techniques for sharing memory. . . 9-8
Changing the tool with speed buttons . . 8-13 Waiting for other threads . . . . . . . . . . . . 9-9
Using drawing tools . . . . . . . . . . . . 8-13 Waiting for a thread to finish
Drawing on a graphic . . . . . . . . . . . . . 8-16 executing . . . . . . . . . . . . . . . . . . 9-9
viii
Waiting for a task to be completed . . . . 9-9 Porting Internet applications to Linux . . 10-29
Executing thread objects . . . . . . . . . . . . . 9-10
Overriding the default priority . . . . . . . . 9-11 Chapter 11
Starting and stopping threads . . . . . . . . 9-11 Working with packages and
Debugging multi-threaded applications . . . . 9-12
components 11-1
Why use packages? . . . . . . . . . . . . . . . . 11-2
Chapter 10 Packages and standard DLLs . . . . . . . . 11-2
Using CLX for cross-platform Runtime packages . . . . . . . . . . . . . . . . 11-2
development 10-1 Using packages in an application . . . . . . 11-3
Creating cross-platform applications . . . . . . 10-1 Dynamically loading packages . . . . . . . 11-4
Porting VCL applications to CLX . . . . . . . . 10-2 Deciding which runtime packages
Porting techniques . . . . . . . . . . . . . . . 10-3 to use . . . . . . . . . . . . . . . . . . . . . 11-4
Platform-specific ports . . . . . . . . . . . 10-3 Custom packages . . . . . . . . . . . . . . . 11-4
Cross-platform ports . . . . . . . . . . . . 10-3 Design-time packages . . . . . . . . . . . . . . 11-5
Windows emulation ports . . . . . . . . . 10-3 Installing component packages . . . . . . . 11-5
Porting your application. . . . . . . . . . . . 10-4 Creating and editing packages . . . . . . . . . 11-6
CLX versus VCL . . . . . . . . . . . . . . . . 10-5 Creating a package . . . . . . . . . . . . . . 11-6
What CLX does differently . . . . . . . . . . 10-6 Editing an existing package . . . . . . . . . 11-7
Look and feel . . . . . . . . . . . . . . . . 10-6 Editing package source files manually . . . 11-8
Styles . . . . . . . . . . . . . . . . . . . . . 10-6 Understanding the structure of a
Variants . . . . . . . . . . . . . . . . . . . 10-7 package . . . . . . . . . . . . . . . . . . . . 11-8
Registry . . . . . . . . . . . . . . . . . . . 10-7 Naming packages . . . . . . . . . . . . . 11-8
Other differences . . . . . . . . . . . . . . 10-7 Requires clause. . . . . . . . . . . . . . . 11-8
Missing in CLX . . . . . . . . . . . . . . . . . 10-8 Contains clause. . . . . . . . . . . . . . . 11-9
Features that will not port . . . . . . . . . . . 10-8 Compiling packages . . . . . . . . . . . . .11-10
CLX and VCL unit comparison . . . . . . . . 10-9 Package-specific compiler
Differences in CLX object directives . . . . . . . . . . . . . . . . .11-10
constructors . . . . . . . . . . . . . . . . . 10-13 Using the command-line compiler
Sharing source files between and linker . . . . . . . . . . . . . . . . .11-12
Windows and Linux . . . . . . . . . . . . 10-13 Package files created by a successful
Environmental differences between compilation . . . . . . . . . . . . . . . .11-12
Windows and Linux . . . . . . . . . . . . 10-14 Deploying packages . . . . . . . . . . . . . . .11-13
Directory structure on Linux . . . . . . . . 10-16 Deploying applications that use
Writing portable code . . . . . . . . . . . . 10-17 packages . . . . . . . . . . . . . . . . . . .11-13
Using conditional directives . . . . . . . 10-18 Distributing packages to other
Terminating conditional directives . . . 10-19 developers . . . . . . . . . . . . . . . . . .11-13
Emitting messages . . . . . . . . . . . . 10-20 Package collection files . . . . . . . . . . . .11-13
Including inline assembler code. . . . . 10-20
Messages and system events . . . . . . . . 10-21 Chapter 12
Programming differences on Linux . . . . 10-22 Creating international applications 12-1
Cross-platform database applications . . . . . 10-23 Internationalization and localization . . . . . . 12-1
dbExpress differences . . . . . . . . . . . . 10-23 Internationalization . . . . . . . . . . . . . . 12-1
Component-level differences . . . . . . . . 10-24 Localization . . . . . . . . . . . . . . . . . . 12-2
User interface-level differences . . . . . . . 10-25 Internationalizing applications . . . . . . . . . 12-2
Porting database applications to Enabling application code . . . . . . . . . . 12-2
Linux . . . . . . . . . . . . . . . . . . . . . 10-25 Character sets . . . . . . . . . . . . . . . 12-2
Updating data in dbExpress OEM and ANSI character sets . . . . . . 12-3
applications . . . . . . . . . . . . . . . . . 10-27 Multibyte character sets. . . . . . . . . . 12-3
Cross-platform Internet applications . . . . . 10-29 Wide characters . . . . . . . . . . . . . . 12-4
ix
Including bi-directional functionality Software license requirements. . . . . . . . . 13-14
in applications . . . . . . . . . . . . . . . 12-4 DEPLOY . . . . . . . . . . . . . . . . . . . 13-14
BiDiMode property . . . . . . . . . . . . . 12-6 README . . . . . . . . . . . . . . . . . . . 13-15
Locale-specific features. . . . . . . . . . . 12-8 No-nonsense license agreement . . . . . . 13-15
Designing the user interface. . . . . . . . . . 12-9 Third-party product documentation . . . 13-15
Text . . . . . . . . . . . . . . . . . . . . . . 12-9
Graphic images . . . . . . . . . . . . . . . 12-9 Part II
Formats and sort order . . . . . . . . . . 12-10 Developing database applications
Keyboard mappings . . . . . . . . . . . 12-10
Isolating resources . . . . . . . . . . . . . . 12-10 Chapter 14
Creating resource DLLs . . . . . . . . . . . 12-10
Using resource DLLs . . . . . . . . . . . . . 12-12 Designing database applications 14-1
Dynamic switching of resource DLLs . . . 12-13 Using databases . . . . . . . . . . . . . . . . . . 14-1
Localizing applications . . . . . . . . . . . . . 12-13 Types of databases. . . . . . . . . . . . . . . 14-2
Localizing resources . . . . . . . . . . . . . 12-13 Database security . . . . . . . . . . . . . . . 14-3
Transactions . . . . . . . . . . . . . . . . . . 14-4
Chapter 13 Referential integrity, stored procedures,
and triggers. . . . . . . . . . . . . . . . . . 14-5
Deploying applications 13-1 Database architecture. . . . . . . . . . . . . . . 14-5
Deploying general applications . . . . . . . . . 13-1
General structure . . . . . . . . . . . . . . . 14-6
Using installation programs. . . . . . . . . . 13-2
The user interface form . . . . . . . . . . 14-6
Identifying application files . . . . . . . . 13-2
The data module . . . . . . . . . . . . . . 14-6
Application files. . . . . . . . . . . . . . . 13-3
Connecting directly to a database
Package files . . . . . . . . . . . . . . . . . 13-3
server . . . . . . . . . . . . . . . . . . . . . 14-7
Merge modules . . . . . . . . . . . . . . . 13-3
Using a dedicated file on disk . . . . . . . . 14-9
ActiveX controls . . . . . . . . . . . . . . 13-5
Connecting to another dataset . . . . . . . 14-10
Helper applications. . . . . . . . . . . . . 13-5
Connecting a client dataset to another
DLL locations . . . . . . . . . . . . . . . . 13-5
dataset in the same application. . . . .14-11
Deploying CLX applications . . . . . . . . . . . 13-6
Using a multi-tiered architecture. . . . 14-12
Deploying database applications. . . . . . . . . 13-6
Combining approaches . . . . . . . . . . . 14-14
Deploying dbExpress database
Designing the user interface . . . . . . . . . . 14-15
applications . . . . . . . . . . . . . . . . . . 13-7
Analyzing data . . . . . . . . . . . . . . . 14-15
Deploying BDE applications . . . . . . . . . 13-8
Writing reports. . . . . . . . . . . . . . . . 14-16
Borland Database Engine . . . . . . . . . 13-8
SQL Links . . . . . . . . . . . . . . . . . . 13-8 Chapter 15
Deploying multi-tiered database
applications (DataSnap) . . . . . . . . . . . 13-9 Using data controls 15-1
Deploying Web applications . . . . . . . . . . . 13-9 Using common data control features . . . . . . 15-2
Deployment on Apache . . . . . . . . . . . 13-10 Associating a data control with a
Programming for varying host dataset . . . . . . . . . . . . . . . . . . . . 15-3
environments . . . . . . . . . . . . . . . . . . 13-11 Changing the associated dataset
Screen resolutions and color depths . . . . 13-11 at runtime . . . . . . . . . . . . . . . . . 15-3
Considerations when not Enabling and disabling the data
dynamically resizing . . . . . . . . . . 13-11 source . . . . . . . . . . . . . . . . . . . 15-4
Considerations when dynamically Responding to changes mediated by
resizing forms and controls . . . . . . 13-12 the data source . . . . . . . . . . . . . . 15-4
Accommodating varying color Editing and updating data . . . . . . . . . . 15-5
depths . . . . . . . . . . . . . . . . . . 13-13 Enabling editing in controls on user
Fonts . . . . . . . . . . . . . . . . . . . . . . 13-13 entry . . . . . . . . . . . . . . . . . . . . 15-5
Operating systems versions . . . . . . . . . 13-14 Editing data in a control. . . . . . . . . . 15-5
x
Disabling and enabling data display . . . . . 15-6 Hiding and showing navigator
Refreshing data display . . . . . . . . . . . . 15-6 buttons at runtime . . . . . . . . . . . 15-29
Enabling mouse, keyboard, and timer Displaying fly-over help . . . . . . . . . . 15-30
events . . . . . . . . . . . . . . . . . . . . . 15-7 Using a single navigator for multiple
Choosing how to organize the data . . . . . . . 15-7 datasets . . . . . . . . . . . . . . . . . . . 15-30
Displaying a single record. . . . . . . . . . . 15-7
Displaying data as labels. . . . . . . . . . 15-8 Chapter 16
Displaying and editing fields in an Using decision support
edit box. . . . . . . . . . . . . . . . . . . 15-8
Displaying and editing text in a
components 16-1
Overview . . . . . . . . . . . . . . . . . . . . . 16-1
memo control . . . . . . . . . . . . . . . 15-8
About crosstabs . . . . . . . . . . . . . . . . . . 16-2
Displaying and editing text in a rich
One-dimensional crosstabs. . . . . . . . . . 16-2
edit memo control. . . . . . . . . . . . . 15-9
Multidimensional crosstabs . . . . . . . . . 16-3
Displaying and editing graphics
Guidelines for using decision support
fields in an image control . . . . . . . . 15-9
components . . . . . . . . . . . . . . . . . . . 16-3
Displaying and editing data in list
Using datasets with decision support
and combo boxes . . . . . . . . . . . . 15-10
components . . . . . . . . . . . . . . . . . . . 16-4
Handling Boolean field values with
Creating decision datasets with TQuery
check boxes . . . . . . . . . . . . . . . 15-12
or TTable . . . . . . . . . . . . . . . . . . . 16-5
Restricting field values with radio
Creating decision datasets with the
controls . . . . . . . . . . . . . . . . . . 15-13
Decision Query editor. . . . . . . . . . . . 16-6
Displaying multiple records. . . . . . . . . 15-14
Using decision cubes . . . . . . . . . . . . . . . 16-7
Viewing and editing data with TDBGrid . . . 15-15
Decision cube properties and events . . . . 16-7
Using a grid control in its default
Using the Decision Cube editor . . . . . . . 16-7
state . . . . . . . . . . . . . . . . . . . . . 15-15
Viewing and changing dimension
Creating a customized grid . . . . . . . . . 15-16
settings . . . . . . . . . . . . . . . . . . 16-8
Understanding persistent columns . . . 15-16
Setting the maximum available
Creating persistent columns . . . . . . . 15-17
dimensions and summaries. . . . . . . 16-8
Deleting persistent columns . . . . . . . 15-18
Viewing and changing design
Arranging the order of persistent
options . . . . . . . . . . . . . . . . . . 16-8
columns . . . . . . . . . . . . . . . . . 15-19
Using decision sources . . . . . . . . . . . . . . 16-9
Setting column properties at design
Properties and events . . . . . . . . . . . . . 16-9
time . . . . . . . . . . . . . . . . . . . . 15-19
Using decision pivots. . . . . . . . . . . . . . . 16-9
Defining a lookup list column . . . . . . 15-20
Decision pivot properties. . . . . . . . . . 16-10
Putting a button in a column . . . . . . 15-21
Creating and using decision grids . . . . . . 16-10
Restoring default values to a
Creating decision grids . . . . . . . . . . . 16-10
column . . . . . . . . . . . . . . . . . . 15-21
Using decision grids . . . . . . . . . . . . .16-11
Displaying ADT and array fields . . . . . . 15-21
Opening and closing decision grid
Setting grid options . . . . . . . . . . . . . 15-23
fields. . . . . . . . . . . . . . . . . . . .16-11
Editing in the grid . . . . . . . . . . . . . . 15-25
Reorganizing rows and columns in
Controlling grid drawing . . . . . . . . . . 15-25
decision grids. . . . . . . . . . . . . . .16-11
Responding to user actions at runtime. . . 15-25
Drilling down for detail in
Creating a grid that contains other
decision grids. . . . . . . . . . . . . . .16-11
data-aware controls . . . . . . . . . . . . . . 15-26
Limiting dimension selection in
Navigating and manipulating records. . . . . 15-28
decision grids. . . . . . . . . . . . . . 16-12
Choosing navigator buttons to
Decision grid properties . . . . . . . . . . 16-12
display . . . . . . . . . . . . . . . . . . . . 15-28
Creating and using decision graphs . . . . . 16-13
Hiding and showing navigator
Creating decision graphs . . . . . . . . . . 16-13
buttons at design time . . . . . . . . . 15-29
Using decision graphs . . . . . . . . . . . 16-13
xi
The decision graph display . . . . . . . . . 16-15 Opening and closing datasets . . . . . . . . . . 18-4
Customizing decision graphs . . . . . . . . 16-15 Navigating datasets. . . . . . . . . . . . . . . . 18-5
Setting decision graph template Using the First and Last methods . . . . . . 18-6
defaults. . . . . . . . . . . . . . . . . . 16-16 Using the Next and Prior methods . . . . . 18-6
Customizing decision graph Using the MoveBy method . . . . . . . . . . 18-7
series . . . . . . . . . . . . . . . . . . . 16-17 Using the Eof and Bof properties . . . . . . 18-7
Decision support components at Eof . . . . . . . . . . . . . . . . . . . . . . 18-7
runtime . . . . . . . . . . . . . . . . . . . . . 16-18 Bof . . . . . . . . . . . . . . . . . . . . . . 18-8
Decision pivots at runtime . . . . . . . . . 16-18 Marking and returning to records . . . . . . 18-9
Decision grids at runtime . . . . . . . . . . 16-18 The Bookmark property. . . . . . . . . . 18-9
Decision graphs at runtime . . . . . . . . . 16-19 The GetBookmark method . . . . . . . . 18-9
Decision support components and The GotoBookmark and Bookmark
memory control . . . . . . . . . . . . . . . . 16-19 Valid methods . . . . . . . . . . . . . . 18-9
Setting maximum dimensions, The CompareBookmarks method . . . . 18-9
summaries, and cells . . . . . . . . . . . . 16-19 The FreeBookmark method . . . . . . . . 18-9
Setting dimension state . . . . . . . . . . . 16-19 A bookmarking example . . . . . . . . 18-10
Using paged dimensions . . . . . . . . . . 16-20 Searching datasets . . . . . . . . . . . . . . . 18-10
Using Locate . . . . . . . . . . . . . . . . . 18-10
Chapter 17 Using Lookup . . . . . . . . . . . . . . . . .18-11
Connecting to databases 17-1 Displaying and editing a subset of data
Using implicit connections . . . . . . . . . . . . 17-2 using filters . . . . . . . . . . . . . . . . . . 18-12
Controlling connections . . . . . . . . . . . . . . 17-2 Enabling and disabling filtering . . . . . . 18-12
Connecting to a database server . . . . . . . 17-3 Creating filters . . . . . . . . . . . . . . . . 18-13
Disconnecting from a database server . . . . 17-3 Setting the Filter property. . . . . . . . 18-13
Controlling server login . . . . . . . . . . . . . . 17-4 Writing an OnFilterRecord event
Managing transactions . . . . . . . . . . . . . . 17-5 handler . . . . . . . . . . . . . . . . . 18-14
Starting a transaction . . . . . . . . . . . . . 17-6 Switching filter event handlers at
Ending a transaction . . . . . . . . . . . . . . 17-7 runtime . . . . . . . . . . . . . . . . . 18-15
Ending a successful transaction . . . . . . 17-8 Setting filter options. . . . . . . . . . . . . 18-15
Ending an unsuccessful transaction . . . 17-8 Navigating records in a filtered
Specifying the transaction isolation dataset . . . . . . . . . . . . . . . . . . . 18-16
level . . . . . . . . . . . . . . . . . . . . . . 17-9 Modifying data . . . . . . . . . . . . . . . . . 18-16
Sending commands to the server . . . . . . . 17-10 Editing records. . . . . . . . . . . . . . . . 18-17
Working with associated datasets . . . . . . . 17-11 Adding new records . . . . . . . . . . . . 18-18
Closing all datasets without dis- Inserting records . . . . . . . . . . . . . 18-19
connecting from the server . . . . . . . . 17-12 Appending records . . . . . . . . . . . 18-19
Iterating through the associated Deleting records . . . . . . . . . . . . . . . 18-19
datasets . . . . . . . . . . . . . . . . . . . 17-12 Posting data . . . . . . . . . . . . . . . . . 18-20
Obtaining metadata . . . . . . . . . . . . . . . 17-12 Canceling changes. . . . . . . . . . . . . . 18-20
Listing available tables. . . . . . . . . . . . 17-13 Modifying entire records . . . . . . . . . . 18-21
Listing the fields in a table . . . . . . . . . 17-13 Calculating fields . . . . . . . . . . . . . . . . 18-22
Listing available stored procedures . . . . 17-13 Types of datasets . . . . . . . . . . . . . . . . 18-23
Listing available indexes . . . . . . . . . . 17-14 Using table-type datasets . . . . . . . . . . . 18-24
Listing stored procedure parameters. . . . 17-14 Advantages of using table-type
datasets . . . . . . . . . . . . . . . . . . . 18-25
Chapter 18 Sorting records with indexes . . . . . . . . 18-25
Understanding datasets 18-1 Obtaining information about
Using TDataSet descendants . . . . . . . . . . . 18-2 indexes . . . . . . . . . . . . . . . . . 18-26
Determining dataset states . . . . . . . . . . . . 18-3
xii
Specifying an index with Setting up parameters at design
IndexName . . . . . . . . . . . . . . . 18-26 time . . . . . . . . . . . . . . . . . . . 18-50
Creating an index with Index Using parameters at runtime . . . . . . 18-52
FieldNames . . . . . . . . . . . . . . . 18-27 Preparing stored procedures . . . . . . . . 18-52
Using Indexes to search for records . . . . 18-27 Executing stored procedures that don’t
Executing a search with Goto return a result set . . . . . . . . . . . . . 18-53
methods . . . . . . . . . . . . . . . . . 18-28 Fetching multiple result sets . . . . . . . . 18-53
Executing a search with Find
methods . . . . . . . . . . . . . . . . . 18-28 Chapter 19
Specifying the current record after a Working with field components 19-1
successful search . . . . . . . . . . . . 18-29 Dynamic field components . . . . . . . . . . . 19-2
Searching on partial keys . . . . . . . . 18-29 Persistent field components . . . . . . . . . . . 19-3
Repeating or extending a search . . . . 18-29 Creating persistent fields . . . . . . . . . . . 19-4
Limiting records with ranges . . . . . . . . 18-30 Arranging persistent fields . . . . . . . . . . 19-5
Understanding the differences between Defining new persistent fields . . . . . . . . 19-5
ranges and filters . . . . . . . . . . . . 18-30 Defining a data field . . . . . . . . . . . . 19-6
Specifying Ranges . . . . . . . . . . . . 18-30 Defining a calculated field . . . . . . . . 19-7
Modifying a range . . . . . . . . . . . . 18-33 Programming a calculated field . . . . . 19-7
Applying or canceling a range . . . . . 18-33 Defining a lookup field . . . . . . . . . . 19-8
Creating master/detail relationships. . . . 18-34 Defining an aggregate field . . . . . . . 19-10
Making the table a detail of another Deleting persistent field components . . . 19-10
dataset . . . . . . . . . . . . . . . . . . 18-34 Setting persistent field properties
Using nested detail tables . . . . . . . . 18-36 and events . . . . . . . . . . . . . . . . . 19-10
Controlling Read/write access to Setting display and edit properties
tables . . . . . . . . . . . . . . . . . . . . . 18-37 at design time. . . . . . . . . . . . . . .19-11
Creating and deleting tables . . . . . . . . 18-37 Setting field component properties
Creating tables . . . . . . . . . . . . . . 18-37 at runtime . . . . . . . . . . . . . . . . 19-12
Deleting tables . . . . . . . . . . . . . . 18-40 Creating attribute sets for field
Emptying tables . . . . . . . . . . . . . . . 18-40 components . . . . . . . . . . . . . . . 19-12
Synchronizing tables . . . . . . . . . . . . . 18-40 Associating attribute sets with field
Using query-type datasets . . . . . . . . . . . 18-41 components . . . . . . . . . . . . . . . 19-13
Specifying the query . . . . . . . . . . . . . 18-42 Removing attribute associations . . . . 19-14
Specifying a query using the SQL Controlling and masking user
property . . . . . . . . . . . . . . . . . 18-42 input . . . . . . . . . . . . . . . . . . . 19-14
Specifying a query using the Using default formatting for numeric,
CommandText property . . . . . . . . 18-43 date, and time fields . . . . . . . . . . 19-14
Using parameters in queries . . . . . . . . 18-43 Handling events . . . . . . . . . . . . . 19-15
Supplying parameters at design Working with field component methods
time . . . . . . . . . . . . . . . . . . . . 18-44 at runtime . . . . . . . . . . . . . . . . . . . 19-16
Supplying parameters at runtime . . . . 18-45 Displaying, converting, and accessing
Establishing master/detail relationships field values. . . . . . . . . . . . . . . . . . . 19-17
using parameters . . . . . . . . . . . . . . 18-46 Displaying field component values in
Preparing queries. . . . . . . . . . . . . . . 18-47 standard controls . . . . . . . . . . . . . 19-17
Executing queries that don’t return a Converting field values . . . . . . . . . . . 19-17
result set . . . . . . . . . . . . . . . . . . . 18-47 Accessing field values with the default
Using unidirectional result sets . . . . . . . 18-48 dataset property . . . . . . . . . . . . . . 19-19
Using stored procedure-type datasets . . . . . 18-48 Accessing field values with a dataset’s
Working with stored procedure Fields property. . . . . . . . . . . . . . . 19-19
parameters. . . . . . . . . . . . . . . . . . 18-50
xiii
Accessing field values with a dataset’s Creating heterogeneous queries . . . . . 20-9
FieldByName method . . . . . . . . . . . 19-20 Obtaining an editable result set . . . . 20-10
Setting a default value for a field. . . . . . . . 19-20 Updating read-only result sets . . . . . .20-11
Working with constraints . . . . . . . . . . . . 19-21 Using TStoredProc . . . . . . . . . . . . . .20-11
Creating a custom constraint . . . . . . . . 19-21 Binding parameters . . . . . . . . . . . 20-12
Using server constraints . . . . . . . . . . . 19-21 Working with Oracle overloaded
Using object fields . . . . . . . . . . . . . . . . 19-22 stored procedures . . . . . . . . . . . 20-12
Displaying ADT and array fields . . . . . . 19-23 Connecting to databases with
Working with ADT fields . . . . . . . . . . 19-23 TDatabase . . . . . . . . . . . . . . . . . 20-12
Using persistent field components . . . 19-24 Associating a database component
Using the dataset’s FieldByName with a session. . . . . . . . . . . . . . 20-13
method . . . . . . . . . . . . . . . . . . 19-24 Understanding database and session
Using the dateset’s FieldValues component interactions . . . . . . . . 20-13
property . . . . . . . . . . . . . . . . . 19-24 Identifying the database . . . . . . . . 20-13
Using the ADT field’s FieldValues Opening a connection using
property . . . . . . . . . . . . . . . . . 19-24 TDatabase . . . . . . . . . . . . . . . . 20-15
Using the ADT field’s Fields Using database components in
property . . . . . . . . . . . . . . . . . 19-25 data modules . . . . . . . . . . . . . . 20-16
Working with array fields . . . . . . . . . . 19-25 Managing database sessions . . . . . . . . 20-16
Using persistent fields . . . . . . . . . . 19-25 Activating a session . . . . . . . . . . . 20-17
Using the array field’s FieldValues Specifying default database
property . . . . . . . . . . . . . . . . . 19-25 connection behavior . . . . . . . . . . 20-18
Using the array field’s Fields Managing database connections . . . . 20-19
property . . . . . . . . . . . . . . . . . 19-26 Working with password-protected
Working with dataset fields . . . . . . . . . 19-26 Paradox and dBASE tables . . . . . . 20-21
Displaying dataset fields . . . . . . . . . 19-26 Specifying Paradox directory
Accessing data in a nested dataset . . . 19-26 locations. . . . . . . . . . . . . . . . . 20-24
Working with reference fields . . . . . . . . 19-27 Working with BDE aliases . . . . . . . 20-24
Displaying reference fields. . . . . . . . 19-27 Retrieving information about a
Accessing data in a reference field . . . 19-27 session . . . . . . . . . . . . . . . . . . 20-26
Creating additional sessions . . . . . . 20-27
Chapter 20 Naming a session . . . . . . . . . . . . 20-28
Using the Borland Database Managing multiple sessions . . . . . . 20-28
Using transactions with the BDE . . . . . . . 20-30
Engine 20-1 Using passthrough SQL . . . . . . . . . . 20-30
BDE-based architecture . . . . . . . . . . . . . . 20-1
Using local transactions . . . . . . . . . . 20-31
Using BDE-enabled datasets . . . . . . . . . 20-2
Using the BDE to cache updates . . . . . . . 20-32
Associating a dataset with database
Enabling BDE-based cached updates . . . 20-33
and session connections . . . . . . . . . 20-3
Applying BDE-based cached updates. . . 20-33
Caching BLOBs . . . . . . . . . . . . . . . 20-4
Applying cached updates using
Obtaining a BDE handle . . . . . . . . . . 20-4
a database . . . . . . . . . . . . . . . . 20-35
Using TTable . . . . . . . . . . . . . . . . . . 20-4
Applying cached updates with dataset
Specifying the table type for local
component methods . . . . . . . . . . 20-35
tables . . . . . . . . . . . . . . . . . . . . 20-5
Creating an OnUpdateRecord
Controlling read/write access to
event handler . . . . . . . . . . . . . . 20-36
local tables . . . . . . . . . . . . . . . . . 20-6
Handling cached update errors . . . . 20-37
Specifying a dBASE index file . . . . . . . 20-6
Using update objects to update a
Renaming local tables . . . . . . . . . . . 20-7
dataset . . . . . . . . . . . . . . . . . . . 20-39
Importing data from another table . . . . 20-8
Using TQuery. . . . . . . . . . . . . . . . . . 20-8
xiv
Creating SQL statements for update Loading data from and saving
components . . . . . . . . . . . . . . . 20-40 data to files . . . . . . . . . . . . . . . 21-14
Using multiple update objects. . . . . . 20-43 Using TADODataSet . . . . . . . . . . . . 21-15
Executing the SQL statements . . . . . . 20-44 Using Command objects . . . . . . . . . . . . 21-16
Using TBatchMove. . . . . . . . . . . . . . . . 20-47 Specifying the command . . . . . . . . . . 21-17
Creating a batch move component . . . . . 20-47 Using the Execute method . . . . . . . . . 21-17
Specifying a batch move mode . . . . . . . 20-49 Canceling commands . . . . . . . . . . . . 21-18
Appending records . . . . . . . . . . . . 20-49 Retrieving result sets with commands . . 21-18
Updating records . . . . . . . . . . . . . 20-49 Handling command parameters . . . . . . 21-19
Appending and updating
records . . . . . . . . . . . . . . . . . . 20-49 Chapter 22
Copying datasets . . . . . . . . . . . . . 20-49 Using unidirectional datasets 22-1
Deleting records. . . . . . . . . . . . . . 20-50 Types of unidirectional datasets . . . . . . . . . 22-2
Mapping data types . . . . . . . . . . . . . 20-50 Connecting to the database server . . . . . . . 22-2
Executing a batch move . . . . . . . . . . . 20-51 Setting up TSQLConnection . . . . . . . . . 22-3
Handling batch move errors . . . . . . . . 20-51 Identifying the driver . . . . . . . . . . . 22-3
The Data Dictionary . . . . . . . . . . . . . . . 20-52 Specifying connection parameters . . . . 22-4
Tools for working with the BDE . . . . . . . . 20-53 Naming a connection description . . . . 22-4
Using the Connection Editor . . . . . . . 22-5
Chapter 21 Specifying what data to display . . . . . . . . . 22-5
Working with ADO components 21-1 Representing the results of a query . . . . . 22-6
Overview of ADO components . . . . . . . . . 21-1 Representing the records in a table . . . . . 22-6
Connecting to ADO data stores . . . . . . . . . 21-2 Representing a table using
Connecting to a data store using TSQLDataSet . . . . . . . . . . . . . . . 22-6
TADOConnection. . . . . . . . . . . . . . . 21-3 Representing a table using
Accessing the connection object . . . . . . 21-4 TSQLTable. . . . . . . . . . . . . . . . . 22-7
Fine-tuning a connection . . . . . . . . . . . 21-4 Representing the results of a stored
Forcing asynchronous connections . . . . 21-5 procedure . . . . . . . . . . . . . . . . . . . 22-7
Controlling timeouts . . . . . . . . . . . . 21-5 Fetching the data . . . . . . . . . . . . . . . . . 22-8
Indicating the types of operations the Preparing the dataset . . . . . . . . . . . . . 22-8
connection supports . . . . . . . . . . . 21-6 Fetching multiple datasets . . . . . . . . . . 22-9
Specifying whether the connection Executing commands that do not return
automatically initiates transactions . . . 21-6 records . . . . . . . . . . . . . . . . . . . . . . 22-9
Accessing the connection’s commands . . . 21-7 Specifying the command to execute. . . . . 22-9
ADO connection events . . . . . . . . . . . . 21-7 Executing the command . . . . . . . . . . 22-10
Events when establishing a Creating and modifying server metadata. 22-10
connection . . . . . . . . . . . . . . . . . 21-7 Setting up master/detail linked cursors . . . 22-12
Events when disconnecting . . . . . . . . 21-8 Accessing schema information . . . . . . . . 22-12
Events when managing transactions . . . 21-8 Fetching metadata into a unidirectional
Other events . . . . . . . . . . . . . . . . . 21-8 dataset . . . . . . . . . . . . . . . . . . . 22-12
Using ADO datasets . . . . . . . . . . . . . . . . 21-9 Fetching data after using the dataset
Connecting an ADO dataset to a for metadata . . . . . . . . . . . . . . 22-13
data store . . . . . . . . . . . . . . . . . 21-9 The structure of metadata datasets . . 22-13
Working with record sets . . . . . . . . 21-10 Debugging dbExpress applications . . . . . . 22-17
Filtering records based on Using TSQLMonitor to monitor SQL
bookmarks . . . . . . . . . . . . . . . . 21-10 commands . . . . . . . . . . . . . . . . . 22-17
Fetching records asynchronously . . . . 21-11 Using a callback to monitor SQL
Using batch updates . . . . . . . . . . . 21-12 commands . . . . . . . . . . . . . . . . . 22-18
xv
Chapter 23 Handling constraints from the server . . . 23-28
Refreshing records. . . . . . . . . . . . . . 23-29
Using client datasets 23-1 Communicating with providers using
Working with data using a client dataset . . . . 23-2
custom events . . . . . . . . . . . . . . . 23-30
Navigating data in client datasets . . . . . . 23-2
Overriding the source dataset . . . . . . . 23-31
Limiting what records appear. . . . . . . . . 23-2
Using a client dataset with file-based data . . 23-31
Editing data . . . . . . . . . . . . . . . . . . . 23-5
Creating a new dataset . . . . . . . . . . . 23-32
Undoing changes . . . . . . . . . . . . . . 23-5
Loading data from a file or stream . . . . 23-32
Saving changes . . . . . . . . . . . . . . . 23-6
Merging changes into data . . . . . . . . . 23-33
Constraining data values . . . . . . . . . . . 23-6
Saving data to a file or stream . . . . . . . 23-33
Specifying custom constraints. . . . . . . 23-7
Sorting and indexing. . . . . . . . . . . . . . 23-7
Adding a new index . . . . . . . . . . . . 23-8
Chapter 24
Deleting and switching indexes . . . . . . 23-9 Using provider components 24-1
Using indexes to group data. . . . . . . . 23-9 Determining the source of data . . . . . . . . . 24-2
Representing calculated values . . . . . . . 23-10 Using a dataset as the source of the
Using internally calculated fields in data . . . . . . . . . . . . . . . . . . . . . . 24-2
client datasets . . . . . . . . . . . . . . 23-10 Using an XML document as the source
Using maintained aggregates . . . . . . . . 23-11 of the data . . . . . . . . . . . . . . . . . . 24-2
Specifying aggregates . . . . . . . . . . 23-11 Communicating with the client dataset . . . . 24-3
Aggregating over groups of Choosing how to apply updates using a
records . . . . . . . . . . . . . . . . . . 23-12 dataset provider . . . . . . . . . . . . . . . . . 24-4
Obtaining aggregate values . . . . . . . 23-13 Controlling what information is included
Copying data from another dataset . . . . 23-13 in data packets. . . . . . . . . . . . . . . . . . 24-4
Assigning data directly. . . . . . . . . . 23-13 Specifying what fields appear in
Cloning a client dataset cursor . . . . . 23-14 data packets . . . . . . . . . . . . . . . . . 24-4
Adding application-specific information Setting options that influence the
to the data . . . . . . . . . . . . . . . . . . 23-14 data packets . . . . . . . . . . . . . . . . . 24-5
Using a client dataset to cache updates . . . . 23-15 Adding custom information to
Overview of using cached updates. . . . . 23-16 data packets . . . . . . . . . . . . . . . . . 24-6
Choosing the type of dataset for caching Responding to client data requests . . . . . . . 24-7
updates . . . . . . . . . . . . . . . . . . . 23-17 Responding to client update requests . . . . . 24-8
Indicating what records are modified . . . 23-18 Editing delta packets before updating the
Updating records . . . . . . . . . . . . . . . 23-19 database . . . . . . . . . . . . . . . . . . . 24-9
Applying updates. . . . . . . . . . . . . 23-19 Influencing how updates are applied . . . . 24-9
Intervening as updates are applied . . . 23-20 Screening individual updates . . . . . . . .24-11
Reconciling update errors . . . . . . . . 23-22 Resolving update errors on the
Using a client dataset with a provider . . . . . 23-23 provider. . . . . . . . . . . . . . . . . . . .24-11
Specifying a provider . . . . . . . . . . . . 23-24 Applying updates to datasets that do
Requesting data from the source dataset not represent a single table . . . . . . . . .24-11
or document. . . . . . . . . . . . . . . . . 23-25 Responding to client-generated events . . . . 24-12
Incremental fetching . . . . . . . . . . . 23-25 Handling server constraints . . . . . . . . . . 24-12
Fetch-on-demand . . . . . . . . . . . . . 23-26
Getting parameters from the source Chapter 25
dataset . . . . . . . . . . . . . . . . . . . . 23-26 Creating multi-tiered applications 25-1
Passing parameters to the source Advantages of the multi-tiered database
dataset . . . . . . . . . . . . . . . . . . . . 23-27 model . . . . . . . . . . . . . . . . . . . . . . . 25-2
Sending query or stored procedure Understanding provider-based multi-tiered
parameters . . . . . . . . . . . . . . . . 23-27 applications . . . . . . . . . . . . . . . . . . . 25-2
Limiting records with parameters . . . 23-28 Overview of a three-tiered application . . . 25-3
xvi
The structure of the client application . . . . 25-4 Dropping or changing a server
The structure of the application server. . . . 25-5 connection . . . . . . . . . . . . . . . 25-28
The contents of the remote data Calling server interfaces . . . . . . . . . . 25-29
module . . . . . . . . . . . . . . . . . . . 25-6 Connecting to an application server
Using transactional data modules . . . . 25-6 that uses multiple data modules . . . . . 25-30
Pooling remote data modules . . . . . . . 25-8 Writing Web-based client applications . . . . 25-31
Choosing a connection protocol . . . . . . . 25-8 Distributing a client application as
Using DCOM connections . . . . . . . . . 25-8 an ActiveX control . . . . . . . . . . . . . 25-32
Using Socket connections . . . . . . . . . 25-9 Creating an Active Form for the client
Using Web connections. . . . . . . . . . . 25-9 application . . . . . . . . . . . . . . . 25-33
Using SOAP connections. . . . . . . . . 25-10 Building Web applications using
Using CORBA connections . . . . . . . 25-10 InternetExpress . . . . . . . . . . . . . . 25-33
Building a multi-tiered application . . . . . . 25-11 Building an InternetExpress
Creating the application server. . . . . . . . . 25-11 application . . . . . . . . . . . . . . . . . 25-34
Setting up the remote data module. . . . . 25-13 Using the javascript libraries . . . . . . 25-35
Configuring TRemoteData- Granting permission to access and
Module . . . . . . . . . . . . . . . . . . 25-13 launch the application server . . . . . 25-36
Configuring TMTSDataModule . . . . . 25-14 Using an XML broker . . . . . . . . . . . . 25-36
Configuring TSoapDataModule. . . . . 25-15 Fetching XML data packets . . . . . . . 25-36
Configuring TCorbaDataModule . . . . 25-15 Applying updates from XML delta
Extending the application server’s packets . . . . . . . . . . . . . . . . . 25-37
interface . . . . . . . . . . . . . . . . . . . 25-16 Creating Web pages with an InternetExpress
Adding callbacks to the application page producer . . . . . . . . . . . . . . . 25-38
server’s interface . . . . . . . . . . . . 25-17 Using the Web page editor . . . . . . . 25-39
Extending a transactional application Setting Web item properties . . . . . . 25-40
server’s interface . . . . . . . . . . . . 25-18 Customizing the InternetExpress page
Managing transactions in multi-tiered producer template . . . . . . . . . . . 25-41
applications . . . . . . . . . . . . . . . . . 25-18
Supporting master/detail Chapter 26
relationships. . . . . . . . . . . . . . . . . 25-19 Using XML in database
Supporting state information in remote
data modules . . . . . . . . . . . . . . . . 25-19
applications 26-1
Defining transformations . . . . . . . . . . . . 26-1
Using multiple remote data modules . . . 25-21
Mapping between XML nodes and data
Registering the application server . . . . . . . 25-22
packet fields . . . . . . . . . . . . . . . . . 26-2
Creating the client application . . . . . . . . . 25-23
Using XMLMapper . . . . . . . . . . . . . . 26-4
Connecting to the application server. . . . 25-23
Loading an XML schema or data
Specifying a connection using
packet . . . . . . . . . . . . . . . . . . . 26-4
DCOM . . . . . . . . . . . . . . . . . . 25-24
Defining mappings . . . . . . . . . . . . 26-4
Specifying a connection using
Generating transformation files . . . . . 26-5
sockets . . . . . . . . . . . . . . . . . . 25-25
Converting XML documents into data
Specifying a connection using
packets . . . . . . . . . . . . . . . . . . . . . . 26-6
HTTP . . . . . . . . . . . . . . . . . . . 25-26
Specifying the source XML document . . . 26-6
Specifying a connection using
Specifying the transformation . . . . . . . . 26-7
SOAP . . . . . . . . . . . . . . . . . . . 25-26
Obtaining the resulting data packet . . . . . 26-7
Specifying a connection using
Converting user-defined nodes . . . . . . . 26-7
CORBA . . . . . . . . . . . . . . . . . . 25-27
Using an XML document as the source for a
Brokering connections . . . . . . . . . . 25-27
provider . . . . . . . . . . . . . . . . . . . . . 26-8
Managing server connections . . . . . . . . 25-28
Using an XML document as the client of
Connecting to the server . . . . . . . . . 25-28
a provider . . . . . . . . . . . . . . . . . . . . 26-9
xvii
Fetching an XML document from The request method type . . . . . . . . . 28-6
a provider . . . . . . . . . . . . . . . . . . . 26-9 Enabling and disabling action items. . . 28-6
Applying updates from an XML Choosing a default action item . . . . . . 28-7
document to a provider . . . . . . . . . . 26-10 Responding to request messages with
action items. . . . . . . . . . . . . . . . . . 28-7
Part III Sending the response . . . . . . . . . . . 28-8
Writing Internet applications Using multiple action items . . . . . . . 28-8
Accessing client request information . . . . . . 28-8
Chapter 27 Properties that contain request header
information. . . . . . . . . . . . . . . . . . 28-9
Creating Internet applications 27-1 Properties that identify the target . . . . 28-9
About Web Broker and WebSnap . . . . . . . . 27-1 Properties that describe the Web
Terminology and standards. . . . . . . . . . . . 27-2 client . . . . . . . . . . . . . . . . . . . . 28-9
Parts of a Uniform Resource Locator. . . . . 27-3 Properties that identify the purpose
URI vs. URL . . . . . . . . . . . . . . . . . 27-3 of the request . . . . . . . . . . . . . . . 28-9
HTTP request header information . . . . . . 27-4 Properties that describe the expected
HTTP server activity. . . . . . . . . . . . . . . . 27-4 response . . . . . . . . . . . . . . . . . 28-10
Composing client requests . . . . . . . . . . 27-4 Properties that describe the
Serving client requests . . . . . . . . . . . . . 27-5 content. . . . . . . . . . . . . . . . . . 28-10
Responding to client requests . . . . . . . . . 27-5 The content of HTTP request
Types of Web server applications . . . . . . . . 27-6 messages . . . . . . . . . . . . . . . . . . 28-10
ISAPI and NSAPI . . . . . . . . . . . . . . 27-6 Creating HTTP response messages . . . . . . 28-10
Apache . . . . . . . . . . . . . . . . . . . . 27-6 Filling in the response header . . . . . . . .28-11
CGI stand-alone. . . . . . . . . . . . . . . 27-6 Indicating the response status . . . . . .28-11
Win-CGI stand-alone . . . . . . . . . . . . 27-7 Indicating the need for client
Debugging server applications . . . . . . . . . . 27-7 action . . . . . . . . . . . . . . . . . . .28-11
Using the Web Application Debugger . . . . 27-7 Describing the server application . . . 28-12
Launching your application with the Describing the content . . . . . . . . . 28-12
Web Application Debugger . . . . . . . 27-7 Setting the response content . . . . . . . . 28-12
Converting your application to another Sending the response . . . . . . . . . . . . 28-12
type of Web server application . . . . . 27-8 Generating the content of response
Debugging Web applications that are messages . . . . . . . . . . . . . . . . . . . . 28-13
DLLs . . . . . . . . . . . . . . . . . . . . . . 27-8 Using page producer components. . . . . 28-13
Debugging under Windows NT. . . . . . 27-9 HTML templates . . . . . . . . . . . . . 28-13
Debugging under Windows 2000 . . . . . 27-9 Specifying the HTML template. . . . . 28-14
Converting HTML-transparent
Chapter 28 tags . . . . . . . . . . . . . . . . . . . 28-14
Using Web Broker 28-1 Using page producers from an
Creating Web server applications with action item . . . . . . . . . . . . . . . 28-15
Web Broker . . . . . . . . . . . . . . . . . . . . 28-1 Chaining page producers
The Web module . . . . . . . . . . . . . . . . 28-2 together . . . . . . . . . . . . . . . . . 28-16
The Web Application object . . . . . . . . . . 28-3 Using database information in
The structure of a Web Broker application . . . 28-3 responses . . . . . . . . . . . . . . . . . . . . 28-17
The Web dispatcher . . . . . . . . . . . . . . . . 28-4 Adding a session to the Web module . . . 28-17
Adding actions to the dispatcher . . . . . . . 28-4 Representing database information
Dispatching request messages . . . . . . . . 28-5 in HTML . . . . . . . . . . . . . . . . . . 28-18
Action items . . . . . . . . . . . . . . . . . . . . 28-5 Using dataset page producers . . . . . 28-18
Determining when action items fire . . . . . 28-6 Using table producers . . . . . . . . . . 28-18
The target URL . . . . . . . . . . . . . . . 28-6 Specifying the table attributes . . . . . 28-18
xviii
Specifying the row attributes . . . . . . 28-19 Script objects . . . . . . . . . . . . . . . . . .29-11
Specifying the columns. . . . . . . . . . 28-19 Dispatching requests . . . . . . . . . . . . . . 29-12
Embedding tables in HTML WebContext . . . . . . . . . . . . . . . . . 29-13
documents . . . . . . . . . . . . . . . . 28-19 Dispatcher components. . . . . . . . . . . 29-13
Setting up a dataset table Adapter dispatcher operation . . . . . . . 29-13
producer . . . . . . . . . . . . . . . . . 28-20 Using adapter components to generate
Setting up a query table producer . . . 28-20 content. . . . . . . . . . . . . . . . . . 29-13
Adapter requests and responses . . . . 29-15
Chapter 29 Action request . . . . . . . . . . . . . . 29-15
Using WebSnap 29-1 Action response . . . . . . . . . . . . . 29-15
Creating Web server applications with Image request . . . . . . . . . . . . . . 29-16
WebSnap . . . . . . . . . . . . . . . . . . . . . 29-2 Image response. . . . . . . . . . . . . . 29-17
Server type . . . . . . . . . . . . . . . . . . . 29-2 Dispatching action items . . . . . . . . . . 29-17
Web application module types . . . . . . . . 29-3 Page dispatcher operation . . . . . . . . . 29-18
Web application module options . . . . . . . 29-3 WebSnap tutorial . . . . . . . . . . . . . . . . 29-18
Application components . . . . . . . . . . . 29-4 Create a new application . . . . . . . . . . 29-19
Web modules . . . . . . . . . . . . . . . . . . . . 29-5 Step 1. Start the WebSnap
Web data modules . . . . . . . . . . . . . . . 29-5 application wizard . . . . . . . . . . . 29-19
Structure of a Web data module Step 2. Save the generated files
unit . . . . . . . . . . . . . . . . . . . . . 29-5 and project . . . . . . . . . . . . . . . 29-19
Interfaces implemented by a Web data Step 3. Specify the application title . . 29-19
module . . . . . . . . . . . . . . . . . . . 29-6 Create a CountryTable page . . . . . . . . 29-20
Web page modules . . . . . . . . . . . . . . . 29-6 Step 1. Add a new module . . . . . . . 29-20
Page producer component . . . . . . . . . 29-6 Step 2. Save the new module . . . . . . 29-20
Page name . . . . . . . . . . . . . . . . . . 29-6 Add data components to the CountryTable
Producer template . . . . . . . . . . . . . 29-6 module . . . . . . . . . . . . . . . . . . . 29-20
Interfaces that the Web page module Step 1. Add data-aware
implements . . . . . . . . . . . . . . . . 29-7 components . . . . . . . . . . . . . . . 29-20
Web application modules . . . . . . . . . . . 29-7 Step 2. Specify a key field . . . . . . . . 29-21
Interfaces implemented by a Web Step 3. Add an adapter component . . 29-21
application data module . . . . . . . . . 29-7 Create a grid to display the data. . . . . . 29-22
Interfaces implemented by a Web Step 1. Add a grid . . . . . . . . . . . . 29-22
application page module . . . . . . . . . 29-7 Step 2. Add editing commands to
Adapters . . . . . . . . . . . . . . . . . . . . . . 29-8 the grid . . . . . . . . . . . . . . . . . 29-22
Fields. . . . . . . . . . . . . . . . . . . . . . . 29-8 Add an edit form . . . . . . . . . . . . . . 29-23
Actions. . . . . . . . . . . . . . . . . . . . . . 29-8 Step 1. Add a new module . . . . . . . 29-23
Errors . . . . . . . . . . . . . . . . . . . . . . 29-8 Step 2. Save the new module . . . . . . 29-23
Records . . . . . . . . . . . . . . . . . . . . . 29-8 Step 3. Use the CountryTableU
Page producers . . . . . . . . . . . . . . . . . . . 29-9 unit . . . . . . . . . . . . . . . . . . . 29-23
Templates . . . . . . . . . . . . . . . . . . . . 29-9 Step 4. Add input fields . . . . . . . . . 29-23
Server-side scripting in WebSnap . . . . . . . . 29-9 Step 5. Add buttons . . . . . . . . . . . 29-24
Active scripting . . . . . . . . . . . . . . . . . 29-9 Step 6. Link form actions to the
Script engine . . . . . . . . . . . . . . . . . 29-10 grid page . . . . . . . . . . . . . . . . 29-24
Script blocks. . . . . . . . . . . . . . . . . . 29-10 Step 7. Link grid actions to the
Creating script . . . . . . . . . . . . . . . . 29-10 form page . . . . . . . . . . . . . . . . 29-24
Wizard templates . . . . . . . . . . . . . 29-10 Add error reporting . . . . . . . . . . . . . 29-25
TAdapterPageProducer . . . . . . . . . 29-10 Step 1. Add error support to the
Editing and viewing script . . . . . . . . . 29-10 grid . . . . . . . . . . . . . . . . . . . 29-25
Including script in a page . . . . . . . . . . 29-11
xix
Step 2. Add error support to the Describing sockets . . . . . . . . . . . . . . . . 32-3
form . . . . . . . . . . . . . . . . . . . 29-25 Describing the host . . . . . . . . . . . . . . 32-4
Step 3. Test the error-reporting Choosing between a host name and
mechanism. . . . . . . . . . . . . . . . 29-26 an IP address . . . . . . . . . . . . . . . 32-4
Run the completed application . . . . . . . 29-26 Using ports . . . . . . . . . . . . . . . . . . . 32-5
Using socket components . . . . . . . . . . . . 32-5
Chapter 30 Getting information about the
Working with XML documents 30-1 connection . . . . . . . . . . . . . . . . . . 32-6
Using the Document Object Model . . . . . . . 30-2 Using client sockets . . . . . . . . . . . . . . 32-6
Working with XML components . . . . . . . . . 30-3 Specifying the desired server . . . . . . . 32-6
Using TXMLDocument . . . . . . . . . . . . 30-3 Forming the connection . . . . . . . . . . 32-6
Working with XML nodes . . . . . . . . . . . 30-4 Getting information about the
Working with a node’s value . . . . . . . 30-4 connection . . . . . . . . . . . . . . . . 32-6
Working with a node’s attributes . . . . . 30-5 Closing the connection . . . . . . . . . . 32-7
Adding and deleting child nodes . . . . . 30-5 Using server sockets . . . . . . . . . . . . . 32-7
Abstracting XML documents with the Specifying the port. . . . . . . . . . . . . 32-7
Data Binding wizard. . . . . . . . . . . . . . . 30-5 Listening for client requests . . . . . . . 32-7
Using the XML Data Binding wizard . . . . 30-7 Connecting to clients . . . . . . . . . . . 32-7
Using code that the XML Data Binding Closing server connections . . . . . . . . 32-7
wizard generates . . . . . . . . . . . . . . . 30-8 Responding to socket events. . . . . . . . . . . 32-8
Error events . . . . . . . . . . . . . . . . . . 32-8
Chapter 31 Client events . . . . . . . . . . . . . . . . . . 32-8
Using Web Services 31-1 Server events. . . . . . . . . . . . . . . . . . 32-9
Writing Servers that support Web Events when listening . . . . . . . . . . . 32-9
Services . . . . . . . . . . . . . . . . . . . . . . 31-2 Events with client connections . . . . . . 32-9
Building a Web Service server . . . . . . . . 31-2 Reading and writing over socket
Defining invokable interfaces . . . . . . . 31-3 connections . . . . . . . . . . . . . . . . . . . 32-9
Using complex types in invokable Non-blocking connections . . . . . . . . . . 32-9
interfaces . . . . . . . . . . . . . . . . . . 31-5 Reading and writing events . . . . . . 32-10
Creating and registering the Blocking connections . . . . . . . . . . . . 32-10
implementation . . . . . . . . . . . . . . 31-6
Creating custom exception classes
Part IV
for Web Services . . . . . . . . . . . . . . 31-7 Developing COM-based applications
Generating WSDL documents for a
Web Service application . . . . . . . . . 31-7 Chapter 33
Writing clients for Web Services . . . . . . . . . 31-8 Overview of COM technologies 33-1
Importing WSDL documents . . . . . . . . . 31-8 COM as a specification and
Calling invokable interfaces. . . . . . . . . . 31-9 implementation . . . . . . . . . . . . . 33-1
COM extensions . . . . . . . . . . . . . . 33-2
Chapter 32 Parts of a COM application . . . . . . . . . . . 33-3
Working with sockets 32-1 COM interfaces . . . . . . . . . . . . . . . . 33-3
Implementing services . . . . . . . . . . . . . . 32-1 The fundamental COM interface,
Understanding service protocols . . . . . . . 32-2 IUnknown . . . . . . . . . . . . . . . . 33-4
Communicating with applications . . . . 32-2 COM interface pointers . . . . . . . . . . 33-4
Services and ports . . . . . . . . . . . . . . . 32-2 COM servers . . . . . . . . . . . . . . . . . . 33-5
Types of socket connections. . . . . . . . . . . . 32-2 CoClasses and class factories . . . . . . . 33-6
Client connections . . . . . . . . . . . . . . . 32-3 In-process, out-of-process, and remote
Listening connections . . . . . . . . . . . . . 32-3 servers . . . . . . . . . . . . . . . . . . . 33-6
Server connections . . . . . . . . . . . . . . . 32-3 The marshaling mechanism . . . . . . . 33-8
xx
Aggregation . . . . . . . . . . . . . . . . . 33-9 Adding an enumeration to the type
COM clients . . . . . . . . . . . . . . . . . . . 33-9 library . . . . . . . . . . . . . . . . . . 34-23
COM extensions . . . . . . . . . . . . . . . . . 33-10 Adding an alias to the type library . . 34-23
Automation servers . . . . . . . . . . . . . 33-12 Adding a record or union to the type
Active Server Pages . . . . . . . . . . . . . 33-12 library . . . . . . . . . . . . . . . . . . 34-24
ActiveX controls . . . . . . . . . . . . . . . 33-13 Adding a module to the type
Active Documents . . . . . . . . . . . . . . 33-13 library . . . . . . . . . . . . . . . . . . 34-24
Transactional objects . . . . . . . . . . . . . 33-14 Saving and registering type library
Type libraries . . . . . . . . . . . . . . . . . 33-15 information . . . . . . . . . . . . . . . 34-24
The content of type libraries . . . . . . . 33-15 Apply Updates dialog. . . . . . . . . . 34-25
Creating type libraries . . . . . . . . . . 33-16 Saving a type library . . . . . . . . . . 34-25
When to use type libraries . . . . . . . . 33-16 Refreshing the type library . . . . . . . 34-26
Accessing type libraries . . . . . . . . . 33-16 Registering the type library. . . . . . . 34-26
Benefits of using type libraries . . . . . 33-17 Exporting an IDL file . . . . . . . . . . 34-26
Using type library tools . . . . . . . . . 33-18 Deploying type libraries . . . . . . . . . . . . 34-27
Implementing COM objects with
wizards . . . . . . . . . . . . . . . . . . . . . 33-18 Chapter 35
Code generated by wizards . . . . . . . . . 33-21 Creating COM clients 35-1
Importing type library information . . . . . . . 35-2
Chapter 34 Using the Import Type Library dialog . . . 35-3
Working with type libraries 34-1 Using the Import ActiveX dialog . . . . . . 35-4
Type Library editor . . . . . . . . . . . . . . . . 34-2 Code generated when you import type
Parts of the Type Library editor. . . . . . . . 34-3 library information . . . . . . . . . . . . . 35-5
Toolbar . . . . . . . . . . . . . . . . . . . . 34-3 Controlling an imported object . . . . . . . . . 35-6
Object list pane . . . . . . . . . . . . . . . 34-5 Using component wrappers . . . . . . . . . 35-6
Status bar . . . . . . . . . . . . . . . . . . 34-5 ActiveX wrappers . . . . . . . . . . . . . 35-6
Pages of type information . . . . . . . . . 34-6 Automation object wrappers . . . . . . . 35-7
Type library elements . . . . . . . . . . . . . 34-8 Using data-aware ActiveX controls . . . . . 35-8
Interfaces. . . . . . . . . . . . . . . . . . . 34-8 Example: Printing a document with
Dispinterfaces . . . . . . . . . . . . . . . . 34-9 Microsoft Word . . . . . . . . . . . . . . . 35-9
CoClasses . . . . . . . . . . . . . . . . . . 34-9 Step 1: Prepare Delphi for this
Type definitions . . . . . . . . . . . . . . 34-10 example . . . . . . . . . . . . . . . . . . 35-9
Modules . . . . . . . . . . . . . . . . . . 34-10 Step 2: Import the Word type
Using the Type Library editor. . . . . . . . 34-11 library . . . . . . . . . . . . . . . . . . 35-10
Valid types . . . . . . . . . . . . . . . . . 34-11 Step 3: Use a VTable or dispatch interface
Using Object Pascal or IDL syntax . . . 34-13 object to control Microsoft Word . . . 35-10
Creating a new type library . . . . . . . 34-19 Step 4: Clean up the example . . . . . . .35-11
Opening an existing type library . . . . 34-19 Writing client code based on type library
Adding an interface to the type definitions . . . . . . . . . . . . . . . . . 35-12
library . . . . . . . . . . . . . . . . . . 34-20 Connecting to a server . . . . . . . . . 35-12
Modifying an interface using the Controlling an Automation server
type library . . . . . . . . . . . . . . . 34-20 using a dual interface . . . . . . . . . 35-12
Adding properties and methods to an Controlling an Automation server
interface or dispinterface . . . . . . . . 34-21 using a dispatch interface . . . . . . . 35-13
Adding a CoClass to the type Handling events in an automation
library . . . . . . . . . . . . . . . . . . 34-22 controller . . . . . . . . . . . . . . . . 35-13
Adding an interface to a CoClass . . . . 34-23 Creating Clients for servers that do not
have a type library . . . . . . . . . . . . . . 35-15
xxi
Chapter 36 Registering an out-of-process server . . . . 37-8
Testing and debugging the Active Server
Creating simple COM servers 36-1 Page application. . . . . . . . . . . . . . . . . 37-8
Overview of creating a COM object . . . . . . . 36-2
Designing a COM object . . . . . . . . . . . . . 36-2
Using the COM object wizard . . . . . . . . . . 36-2
Chapter 38
Using the Automation object wizard . . . . . . 36-4 Creating an ActiveX control 38-1
COM object instancing types . . . . . . . . . 36-5 Overview of ActiveX control creation . . . . . 38-2
Choosing a threading model . . . . . . . . . 36-6 Elements of an ActiveX control . . . . . . . 38-2
Writing an object that supports the free VCL control. . . . . . . . . . . . . . . . . 38-3
threading model. . . . . . . . . . . . . . 36-7 ActiveX wrapper. . . . . . . . . . . . . . 38-3
Writing an object that supports the Type library. . . . . . . . . . . . . . . . . 38-3
apartment threading model . . . . . . . 36-8 Property page . . . . . . . . . . . . . . . 38-3
Writing an object that supports the Designing an ActiveX control . . . . . . . . . . 38-4
neutral threading model . . . . . . . . . 36-9 Generating an ActiveX control from a
Defining a COM object’s interface . . . . . . . . 36-9 VCL control . . . . . . . . . . . . . . . . . . . 38-4
Adding a property to the object’s Generating an ActiveX control based on
interface . . . . . . . . . . . . . . . . . . . . 36-9 a VCL form. . . . . . . . . . . . . . . . . . . . 38-5
Adding a method to the object’s Licensing ActiveX controls. . . . . . . . . . . . 38-6
interface . . . . . . . . . . . . . . . . . . . 36-10 Customizing the ActiveX control’s
Exposing events to clients . . . . . . . . . . 36-10 interface . . . . . . . . . . . . . . . . . . . . . 38-7
Managing events in your Adding additional properties, methods,
Automation object . . . . . . . . . . . 36-12 and events . . . . . . . . . . . . . . . . . . 38-8
Automation interfaces . . . . . . . . . . . . . . 36-12 Adding properties and methods . . . . . 38-8
Dual interfaces . . . . . . . . . . . . . . . . 36-13 Adding events . . . . . . . . . . . . . . . 38-9
Dispatch interfaces . . . . . . . . . . . . . . 36-14 Enabling simple data binding with the
Custom interfaces . . . . . . . . . . . . . . 36-14 type library . . . . . . . . . . . . . . . . . 38-10
Marshaling data . . . . . . . . . . . . . . . . . 36-15 Creating a property page for an ActiveX
Automation compatible types . . . . . . . 36-15 control . . . . . . . . . . . . . . . . . . . . . .38-11
Type restrictions for automatic Creating a new property page . . . . . . . 38-12
marshaling . . . . . . . . . . . . . . . . . 36-16 Adding controls to a property page . . . . 38-12
Custom marshaling . . . . . . . . . . . . . 36-16 Associating property page controls with
Registering a COM object . . . . . . . . . . . . 36-16 ActiveX control properties . . . . . . . . 38-13
Registering an in-process server . . . . . . 36-17 Updating the property page . . . . . . 38-13
Registering an out-of-process server . . . . 36-17 Updating the object . . . . . . . . . . . 38-13
Testing and debugging the application . . . . 36-17 Connecting a property page to an ActiveX
control. . . . . . . . . . . . . . . . . . . . 38-14
Chapter 37 Registering an ActiveX control . . . . . . . . 38-14
Testing an ActiveX control . . . . . . . . . . . 38-14
Creating an Active Server Page 37-1 Deploying an ActiveX control on the
Creating an Active Server Object. . . . . . . . . 37-2
Web . . . . . . . . . . . . . . . . . . . . . . . 38-15
Using the ASP intrinsics . . . . . . . . . . . . 37-3
Setting options . . . . . . . . . . . . . . . . 38-16
Application . . . . . . . . . . . . . . . . . 37-4
Request. . . . . . . . . . . . . . . . . . . . 37-4
Response . . . . . . . . . . . . . . . . . . . 37-5
Chapter 39
Session . . . . . . . . . . . . . . . . . . . . 37-5 Creating MTS or COM+ objects 39-1
Server . . . . . . . . . . . . . . . . . . . . 37-6 Understanding transactional objects . . . . . . 39-2
Creating ASPs for in-process or Requirements for a transactional
out-of-process servers . . . . . . . . . . . . 37-7 object . . . . . . . . . . . . . . . . . . . . . 39-3
Registering an Active Server Object . . . . . . . 37-7 Managing resources . . . . . . . . . . . . . . . 39-3
Registering an in-process server . . . . . . . 37-7 Accessing the object context . . . . . . . . . 39-4
xxii
Just-in-time activation . . . . . . . . . . . . . 39-4 Creating nonvisual components . . . . . . . 40-5
Resource pooling . . . . . . . . . . . . . . . . 39-5 What goes into a component? . . . . . . . . . . 40-5
Database resource dispensers . . . . . . . 39-5 Removing dependencies . . . . . . . . . . . 40-5
Shared property manager . . . . . . . . . 39-6 Properties, methods, and events . . . . . . . 40-6
Releasing resources . . . . . . . . . . . . . 39-7 Properties . . . . . . . . . . . . . . . . . . 40-6
Object pooling . . . . . . . . . . . . . . . . . 39-8 Events . . . . . . . . . . . . . . . . . . . . 40-6
MTS and COM+ transaction support . . . . . . 39-8 Methods. . . . . . . . . . . . . . . . . . . 40-6
Transaction attributes . . . . . . . . . . . . . 39-9 Graphics encapsulation . . . . . . . . . . . . 40-7
Setting the transaction attribute . . . . . 39-10 Registration . . . . . . . . . . . . . . . . . . 40-8
Stateful and stateless objects . . . . . . . . 39-11 Creating a new component . . . . . . . . . . . 40-8
Influencing how transactions end . . . . . 39-11 Using the Component wizard . . . . . . . . 40-9
Initiating transactions . . . . . . . . . . . . 39-12 Creating a component manually. . . . . . .40-11
Setting up a transaction object on Creating a unit file . . . . . . . . . . . . .40-11
the client side . . . . . . . . . . . . . . 39-12 Deriving the component . . . . . . . . .40-11
Setting up a transaction object on Registering the component. . . . . . . 40-12
the server side . . . . . . . . . . . . . . 39-13 Testing uninstalled components. . . . . . . . 40-12
Transaction timeout . . . . . . . . . . . . . 39-14 Testing installed components . . . . . . . . . 40-14
Role-based security . . . . . . . . . . . . . . . 39-14
Overview of creating transactional Chapter 41
objects . . . . . . . . . . . . . . . . . . . . . . 39-15 Object-oriented programming for
Using the Transactional Object wizard . . . . 39-15
Choosing a threading model for a
component writers 41-1
Defining new classes . . . . . . . . . . . . . . . 41-1
transactional object . . . . . . . . . . . . . 39-16
Deriving new classes . . . . . . . . . . . . . 41-2
Activities . . . . . . . . . . . . . . . . . . 39-17
To change class defaults to avoid
Generating events under COM+ . . . . . . . . 39-18
repetition . . . . . . . . . . . . . . . . . 41-2
Using the Event Object wizard . . . . . . . 39-19
To add new capabilities to a class . . . . 41-2
Firing events using a COM+ event
Declaring a new component class . . . . . . 41-3
object . . . . . . . . . . . . . . . . . . . . . 39-20
Ancestors, descendants, and class
Passing object references . . . . . . . . . . . . 39-20
hierarchies . . . . . . . . . . . . . . . . . . . . 41-3
Using the SafeRef method . . . . . . . . 39-20
Controlling access. . . . . . . . . . . . . . . . . 41-4
Callbacks. . . . . . . . . . . . . . . . . . 39-21
Hiding implementation details . . . . . . . 41-4
Debugging and testing transactional
Defining the component writer’s
objects . . . . . . . . . . . . . . . . . . . . . . 39-21
interface. . . . . . . . . . . . . . . . . . . . 41-5
Installing transactional objects . . . . . . . . . 39-22
Defining the runtime interface . . . . . . . . 41-6
Administering transactional objects . . . . . . 39-23
Defining the design-time interface . . . . . 41-6
Dispatching methods . . . . . . . . . . . . . . . 41-7
Part V Static methods . . . . . . . . . . . . . . . . . 41-7
Creating custom components An example of static methods . . . . . . 41-7
Virtual methods . . . . . . . . . . . . . . . . 41-8
Chapter 40 Overriding methods . . . . . . . . . . . . 41-8
Overview of component creation 40-1 Abstract class members . . . . . . . . . . . . . 41-9
VCL and CLX. . . . . . . . . . . . . . . . . . . . 40-1 Classes and pointers . . . . . . . . . . . . . . . 41-9
Components and classes . . . . . . . . . . . . . 40-2
How do you create components? . . . . . . . . 40-2 Chapter 42
Modifying existing controls . . . . . . . . . . 40-3 Creating properties 42-1
Creating windowed controls . . . . . . . . . 40-3 Why create properties? . . . . . . . . . . . . . . 42-1
Creating graphic controls . . . . . . . . . . . 40-4 Types of properties . . . . . . . . . . . . . . . . 42-2
Subclassing Windows controls . . . . . . . . 40-4 Publishing inherited properties . . . . . . . . . 42-2
xxiii
Defining properties . . . . . . . . . . . . . . . . 42-3 Declaring the event . . . . . . . . . . . . . . 43-8
The property declaration . . . . . . . . . . . 42-3 Event names start with “On” . . . . . . . 43-8
Internal data storage . . . . . . . . . . . . . . 42-4 Calling the event. . . . . . . . . . . . . . . . 43-8
Direct access. . . . . . . . . . . . . . . . . . . 42-4
Access methods. . . . . . . . . . . . . . . . . 42-5 Chapter 44
The read method . . . . . . . . . . . . . . 42-6 Creating methods 44-1
The write method . . . . . . . . . . . . . . 42-6 Avoiding dependencies . . . . . . . . . . . . . 44-1
Default property values . . . . . . . . . . . . 42-7 Naming methods . . . . . . . . . . . . . . . . . 44-2
Specifying no default value . . . . . . . . 42-7 Protecting methods . . . . . . . . . . . . . . . . 44-2
Creating array properties . . . . . . . . . . . . . 42-8 Methods that should be public. . . . . . . . 44-3
Creating properties for subcomponents . . . . . 42-8 Methods that should be protected . . . . . . 44-3
Creating properties for interfaces . . . . . . . 42-10 Abstract methods . . . . . . . . . . . . . . . 44-3
Storing and loading properties . . . . . . . . . 42-11 Making methods virtual . . . . . . . . . . . . . 44-4
Using the store-and-load mechanism . . . 42-11 Declaring methods . . . . . . . . . . . . . . . . 44-4
Specifying default values . . . . . . . . . . 42-11
Determining what to store. . . . . . . . . . 42-12 Chapter 45
Initializing after loading . . . . . . . . . . . 42-13 Using graphics in components 45-1
Storing and loading unpublished Overview of graphics. . . . . . . . . . . . . . . 45-1
properties . . . . . . . . . . . . . . . . . . 42-13 Using the canvas . . . . . . . . . . . . . . . . . 45-3
Creating methods to store and load Working with pictures . . . . . . . . . . . . . . 45-3
property values . . . . . . . . . . . . . 42-14 Using a picture, graphic, or canvas . . . . . 45-3
Overriding the DefineProperties Loading and storing graphics . . . . . . . . 45-4
method . . . . . . . . . . . . . . . . . . 42-14 Handling palettes . . . . . . . . . . . . . . . 45-5
Specifying a palette for a control . . . . . 45-5
Chapter 43 Off-screen bitmaps . . . . . . . . . . . . . . . . 45-6
Creating events 43-1 Creating and managing off-screen
What are events? . . . . . . . . . . . . . . . . . . 43-1 bitmaps . . . . . . . . . . . . . . . . . . . . 45-6
Events are method pointers . . . . . . . . . . 43-2 Copying bitmapped images . . . . . . . . . 45-6
Events are properties. . . . . . . . . . . . . . 43-2 Responding to changes. . . . . . . . . . . . . . 45-7
Event types are method-pointer types . . . . 43-3
Event-handler types are procedures . . . 43-3 Chapter 46
Event handlers are optional . . . . . . . . . . 43-4 Handling messages 46-1
Implementing the standard events. . . . . . . . 43-4 Understanding the message-handling
Identifying standard events . . . . . . . . . . 43-4 system . . . . . . . . . . . . . . . . . . . . . . 46-1
Standard events for all controls . . . . . . 43-4 What’s in a Windows message? . . . . . . . 46-2
Standard events for standard Dispatching messages. . . . . . . . . . . . . 46-2
controls . . . . . . . . . . . . . . . . . . . 43-5 Tracing the flow of messages . . . . . . . 46-3
Making events visible . . . . . . . . . . . . . 43-5 Changing message handling. . . . . . . . . . . 46-3
Changing the standard event handling . . . 43-6 Overriding the handler method . . . . . . . 46-3
Defining your own events . . . . . . . . . . . . 43-6 Using message parameters . . . . . . . . . . 46-4
Triggering the event . . . . . . . . . . . . . . 43-7 Trapping messages . . . . . . . . . . . . . . 46-4
Two kinds of events . . . . . . . . . . . . 43-7 Creating new message handlers. . . . . . . . . 46-5
Defining the handler type . . . . . . . . . . . 43-7 Defining your own messages . . . . . . . . 46-5
Simple notifications. . . . . . . . . . . . . 43-7 Declaring a message identifier . . . . . . 46-6
Event-specific handlers. . . . . . . . . . . 43-7 Declaring a message-record type. . . . . 46-6
Returning information from the Declaring a new message-handling
handler . . . . . . . . . . . . . . . . . . . 43-8 method . . . . . . . . . . . . . . . . . . . . 46-7
xxiv
Chapter 47 Chapter 49
Making components available at Creating a graphic component 49-1
design time 47-1 Creating and registering the component . . . . 49-1
Registering components. . . . . . . . . . . . . . 47-1 Publishing inherited properties . . . . . . . . . 49-2
Declaring the Register procedure. . . . . . . 47-2 Adding graphic capabilities . . . . . . . . . . . 49-3
Writing the Register procedure . . . . . . . . 47-2 Determining what to draw . . . . . . . . . . 49-3
Specifying the components . . . . . . . . 47-2 Declaring the property type . . . . . . . 49-3
Specifying the palette page . . . . . . . . 47-3 Declaring the property . . . . . . . . . . 49-4
Using the RegisterComponents Writing the implementation method . . 49-4
function . . . . . . . . . . . . . . . . . . 47-3 Overriding the constructor and
Adding palette bitmaps . . . . . . . . . . . . . . 47-3 destructor. . . . . . . . . . . . . . . . . . . 49-4
Providing Help for your component. . . . . . . 47-4 Changing default property values . . . . 49-4
Creating the Help file . . . . . . . . . . . . . 47-4 Publishing the pen and brush . . . . . . . . 49-5
Creating the entries . . . . . . . . . . . . . 47-4 Declaring the class fields . . . . . . . . . 49-5
Making component help Declaring the access properties. . . . . . 49-6
context-sensitive . . . . . . . . . . . . . 47-6 Initializing owned classes. . . . . . . . . 49-6
Adding component help files . . . . . . . 47-6 Setting owned classes’ properties . . . . 49-7
Adding property editors . . . . . . . . . . . . . 47-6 Drawing the component image . . . . . . . 49-8
Deriving a property-editor class . . . . . . . 47-7 Refining the shape drawing . . . . . . . . . 49-9
Editing the property as text . . . . . . . . . . 47-8
Displaying the property value. . . . . . . 47-8 Chapter 50
Setting the property value . . . . . . . . . 47-8 Customizing a grid 50-1
Editing the property as a whole . . . . . . . 47-9 Creating and registering the component . . . . 50-1
Specifying editor attributes . . . . . . . . . 47-10 Publishing inherited properties . . . . . . . . . 50-2
Registering the property editor . . . . . . . 47-11 Changing initial values. . . . . . . . . . . . . . 50-3
Property categories . . . . . . . . . . . . . . . 47-12 Resizing the cells . . . . . . . . . . . . . . . . . 50-4
Registering one property at a time . . . . . 47-13 Filling in the cells . . . . . . . . . . . . . . . . . 50-5
Registering multiple properties at Tracking the date . . . . . . . . . . . . . . . 50-5
once . . . . . . . . . . . . . . . . . . . . . 47-13 Storing the internal date . . . . . . . . . 50-6
Specifying property categories . . . . . . . 47-14 Accessing the day, month, and year . . . 50-6
Using the IsPropertyInCategory Generating the day numbers . . . . . . . 50-8
function . . . . . . . . . . . . . . . . . . . 47-15 Selecting the current day . . . . . . . . . 50-9
Adding component editors . . . . . . . . . . . 47-15 Navigating months and years . . . . . . . . . 50-10
Adding items to the context menu . . . . . 47-16 Navigating days. . . . . . . . . . . . . . . . . .50-11
Specifying menu items . . . . . . . . . . 47-16 Moving the selection . . . . . . . . . . . . .50-11
Implementing commands . . . . . . . . 47-16 Providing an OnChange event. . . . . . . .50-11
Changing the double-click behavior . . . . 47-17 Excluding blank cells . . . . . . . . . . . . 50-12
Adding clipboard formats . . . . . . . . . . 47-18
Registering the component editor . . . . . 47-18 Chapter 51
Compiling components into packages. . . . . 47-19 Making a control data aware 51-1
Creating a data-browsing control . . . . . . . . 51-1
Chapter 48 Creating and registering the
Modifying an existing component 48-1 component . . . . . . . . . . . . . . . . . . 51-2
Creating and registering the component . . . . 48-1 Making the control read-only . . . . . . . . 51-2
Modifying the component class . . . . . . . . . 48-2 Adding the ReadOnly property . . . . . 51-3
Overriding the constructor . . . . . . . . . . 48-2 Allowing needed updates. . . . . . . . . 51-3
Specifying the new default property Adding the data link . . . . . . . . . . . . . 51-4
value . . . . . . . . . . . . . . . . . . . . . . 48-3 Declaring the class field . . . . . . . . . . 51-4
xxv
Declaring the access properties . . . . . . 51-5 Modifying the Change method . . . . . . .51-11
An example of declaring access Updating the dataset . . . . . . . . . . . . .51-11
properties . . . . . . . . . . . . . . . . . 51-5
Initializing the data link . . . . . . . . . . 51-6 Chapter 52
Responding to data changes . . . . . . . . . 51-6 Making a dialog box a component 52-1
Creating a data-editing control . . . . . . . . . . 51-7 Defining the component interface. . . . . . . . 52-1
Changing the default value of Creating and registering the component . . . . 52-2
FReadOnly . . . . . . . . . . . . . . . . . . 51-8 Creating the component interface. . . . . . . . 52-3
Handling mouse-down and key-down Including the form unit . . . . . . . . . . . . 52-3
messages. . . . . . . . . . . . . . . . . . . . 51-8 Adding interface properties . . . . . . . . . 52-3
Responding to mouse-down Adding the Execute method . . . . . . . . . 52-4
messages . . . . . . . . . . . . . . . . . . 51-8 Testing the component . . . . . . . . . . . . . . 52-6
Responding to key-down messages . . . 51-9
Updating the field datalink class . . . . . . 51-10 Index I-1
xxvi
Tables
1.1 Typefaces and symbols . . . . . . . . . . . 1-3 8.5 Multimedia device types and their
3.1 Important base classes . . . . . . . . . . . 3-13 functions . . . . . . . . . . . . . . . . . . . 8-32
3.2 Graphic controls . . . . . . . . . . . . . . . 3-17 9.1 Thread priorities . . . . . . . . . . . . . . . 9-3
3.3 Component palette pages . . . . . . . . . 3-29 9.2 WaitFor return values . . . . . . . . . . . 9-10
3.4 Text control properties . . . . . . . . . . . 3-31 10.1 Porting techniques . . . . . . . . . . . . . 10-3
3.5 Components for creating and 10.2 CLX parts . . . . . . . . . . . . . . . . . . 10-6
managing lists . . . . . . . . . . . . . . . . 3-47 10.3 Changed or different features . . . . . . . 10-9
4.1 RTL exceptions . . . . . . . . . . . . . . . . 4-9 10.4 VCL and equivalent CLX units . . . . . 10-10
4.2 Object Pascal character types . . . . . . . . 4-40 10.5 Units in CLX, not VCL . . . . . . . . . . .10-11
4.3 String comparison routines . . . . . . . . . 4-44 10.6 VCL-only units . . . . . . . . . . . . . . .10-11
4.4 Case conversion routines . . . . . . . . . . 4-44 10.7 Differences in the Linux and Windows
4.5 String modification routines . . . . . . . . 4-45 operating environments . . . . . . . . . 10-14
4.6 Sub-string routines . . . . . . . . . . . . . 4-45 10.8 Common Linux directories . . . . . . . 10-16
4.7 String handling routines . . . . . . . . . . 4-45 10.9 TWidgetControl protected methods
4.8 Compiler directives for strings . . . . . . . 4-49 for responding to system events . . . . 10-21
4.9 Attribute constants and values . . . . . . . 4-51 10.10 Comparable data-access
4.10 File types for file I/O . . . . . . . . . . . . 4-53 components . . . . . . . . . . . . . . . . 10-24
4.11 Open modes . . . . . . . . . . . . . . . . . 4-54 10.11 Properties, methods, and events
4.12 Shared modes . . . . . . . . . . . . . . . . 4-54 for cached updates . . . . . . . . . . . . 10-28
4.13 Shared modes available for each 11.1 Compiled package files . . . . . . . . . . 11-2
open mode . . . . . . . . . . . . . . . . . . 4-55 11.2 Package-specific compiler
5.1 Compiler directives for libraries . . . . . . 5-9 directives . . . . . . . . . . . . . . . . . .11-10
5.2 Database pages on the Component 11.3 Package-specific command-line
palette . . . . . . . . . . . . . . . . . . . . . 5-10 compiler switches. . . . . . . . . . . . . .11-12
5.3 Web server applications . . . . . . . . . . . 5-12 11.4 Compiled package files . . . . . . . . . .11-12
5.4 Context menu options for data 12.1 VCL objects that support BiDi. . . . . . . 12-4
modules. . . . . . . . . . . . . . . . . . . . 5-16 12.2 Estimating string lengths . . . . . . . . . 12-9
5.5 Help methods in TApplication . . . . . . . 5-28 13.1 Application files . . . . . . . . . . . . . . 13-3
6.1 Action setup terminology. . . . . . . . . . 6-16 13.2 Merge modules and their
6.2 Default values of the action manager’s dependencies . . . . . . . . . . . . . . . . 13-4
PrioritySchedule property . . . . . . . . . 6-22 13.3 dbExpress deployment as standalone
6.3 Action classes . . . . . . . . . . . . . . . . 6-27 executable . . . . . . . . . . . . . . . . . . 13-7
6.4 Sample captions and their derived 13.4 dbExpress deployment, driver DLLs . . . 13-7
names . . . . . . . . . . . . . . . . . . . . . 6-31 13.5 SQL database client software files . . . . 13-9
6.5 Menu Designer context menu 15.1 Data controls . . . . . . . . . . . . . . . . 15-2
commands . . . . . . . . . . . . . . . . . . 6-36 15.2 Column properties . . . . . . . . . . . . 15-19
6.6 Setting speed buttons’ appearance. . . . . 6-44 15.3 Expanded TColumn Title
6.7 Setting tool buttons’ appearance . . . . . . 6-46 properties . . . . . . . . . . . . . . . . . 15-20
6.8 Setting a cool button’s appearance. . . . . 6-47 15.4 Properties that affect the way
7.1 Properties of selected text. . . . . . . . . . 7-8 composite fields appear . . . . . . . . . 15-23
7.2 Fixed vs. variable owner-draw styles . . . 7-12 15.5 Expanded TDBGrid Options
8.1 Graphic object types . . . . . . . . . . . . . 8-3 properties . . . . . . . . . . . . . . . . . 15-24
8.2 Common properties of the Canvas 15.6 Grid control events . . . . . . . . . . . . 15-26
object . . . . . . . . . . . . . . . . . . . . . 8-4 15.7 Selected database control grid
8.3 Common methods of the Canvas properties . . . . . . . . . . . . . . . . . 15-27
object . . . . . . . . . . . . . . . . . . . . . 8-4 15.8 TDBNavigator buttons . . . . . . . . . . 15-28
8.4 Mouse-event parameters . . . . . . . . . . 8-24 17.1 Database connection components . . . . 17-1
xxvii
18.1 Values for the dataset State property . . . 18-3 22.5 Columns in tables of metadata listing
18.2 Navigational methods of datasets . . . . . 18-5 parameters. . . . . . . . . . . . . . . . . 22-16
18.3 Navigational properties of datasets . . . . 18-6 23.1 Filter support in client datasets . . . . . . 23-3
18.4 Comparison and logical operators 23.2 Summary operators for maintained
that can appear in a filter . . . . . . . . 18-14 aggregates . . . . . . . . . . . . . . . . . .23-11
18.5 FilterOptions values . . . . . . . . . . . . 18-15 23.3 Specialized client datasets for
18.6 Filtered dataset navigational caching updates. . . . . . . . . . . . . . 23-17
methods. . . . . . . . . . . . . . . . . . . 18-16 24.1 AppServer interface members. . . . . . . 24-3
18.7 Dataset methods for inserting, 24.2 Provider options . . . . . . . . . . . . . . 24-5
updating, and deleting data . . . . . . . 18-17 24.3 UpdateStatus values . . . . . . . . . . . . 24-9
18.8 Methods that work with entire 24.4 UpdateMode values . . . . . . . . . . . 24-10
records . . . . . . . . . . . . . . . . . . . 18-21 24.5 ProviderFlags values . . . . . . . . . . . 24-10
18.9 Index-based search methods . . . . . . . 18-27 25.1 Components used in multi-tiered
19.1 TFloatField properties that affect applications . . . . . . . . . . . . . . . . . 25-3
data display . . . . . . . . . . . . . . . . . 19-1 25.2 Connection components . . . . . . . . . . 25-5
19.2 Special persistent field kinds . . . . . . . . 19-6 25.3 Javascript libraries . . . . . . . . . . . . 25-35
19.3 Field component properties . . . . . . . 19-11 27.1 Web Broker versus WebSnap . . . . . . . 27-2
19.4 Field component formatting 27.2 Web server application components . . . 27-6
routines . . . . . . . . . . . . . . . . . . . 19-15 28.1 MethodType values. . . . . . . . . . . . . 28-6
19.5 Field component events. . . . . . . . . . 19-15 33.1 COM object requirements . . . . . . . . .33-11
19.6 Selected field component methods . . . 19-16 33.2 Delphi wizards for implementing COM,
19.7 Special conversion results. . . . . . . . . 19-19 Automation, and ActiveX objects . . . . 33-19
19.8 Types of object field components . . . . 19-22 33.3 DAX Base classes for generated
19.9 Common object field descendant implementation classes . . . . . . . . . 33-21
properties . . . . . . . . . . . . . . . . . . 19-23 34.1 Type Library editor files . . . . . . . . . . 34-2
20.1 Table types recognized by the BDE 34.2 Type Library editor parts . . . . . . . . . 34-3
based on file extension . . . . . . . . . . . 20-5 34.3 Type library pages . . . . . . . . . . . . . 34-6
20.2 TableType values. . . . . . . . . . . . . . . 20-5 34.4 Valid types. . . . . . . . . . . . . . . . . 34-12
20.3 BatchMove import modes . . . . . . . . . 20-8 34.5 Attribute syntax. . . . . . . . . . . . . . 34-14
20.4 Database-related informational methods 36.1 Threading models for COM objects . . . 36-6
for session components . . . . . . . . . . 20-26 37.1 IApplicationObject interface
20.5 TSessionList properties and members . . . . . . . . . . . . . . . . . . . 37-4
methods. . . . . . . . . . . . . . . . . . . 20-29 37.2 IRequest interface members . . . . . . . . 37-4
20.6 Properties, methods, and events for 37.3 IResponse interface members . . . . . . . 37-5
cached updates. . . . . . . . . . . . . . . 20-32 37.4 ISessionObject interface members . . . . 37-6
20.7 UpdateKind values . . . . . . . . . . . . 20-38 37.5 IServer interface members . . . . . . . . . 37-6
20.8 Batch move modes. . . . . . . . . . . . . 20-49 39.1 IObjectContext methods for transaction
20.9 Data Dictionary interface . . . . . . . . . 20-52 support. . . . . . . . . . . . . . . . . . . .39-11
21.1 ADO components . . . . . . . . . . . . . . 21-2 39.2 Threading models for transactional
21.2 ADO connection modes . . . . . . . . . . 21-6 objects . . . . . . . . . . . . . . . . . . . 39-17
21.3 Execution options for ADO 39.3 Call synchronization options . . . . . . 39-18
datasets . . . . . . . . . . . . . . . . . . . 21-12 40.1 Component creation starting points . . . 40-3
21.4 Comparison of ADO and client dataset 41.1 Levels of visibility within an object . . . . 41-4
cached updates. . . . . . . . . . . . . . . 21-12 42.1 How properties appear in the Object
22.1 Columns in tables of metadata listing Inspector . . . . . . . . . . . . . . . . . . . 42-2
tables . . . . . . . . . . . . . . . . . . . . 22-14 45.1 Canvas capability summary . . . . . . . . 45-3
22.2 Columns in tables of metadata listing 45.2 Image-copying methods . . . . . . . . . . 45-7
stored procedures . . . . . . . . . . . . . 22-14 47.1 Predefined property-editor types . . . . . 47-7
22.3 Columns in tables of metadata listing 47.2 Methods for reading and writing
fields . . . . . . . . . . . . . . . . . . . . 22-15 property values . . . . . . . . . . . . . . . 47-8
22.4 Columns in tables of metadata listing 47.3 Property-editor attribute flags. . . . . . 47-10
indexes . . . . . . . . . . . . . . . . . . . 22-16 47.4 Property categories . . . . . . . . . . . . 47-14
xxviii
Figures
3.1 A simple form . . . . . . . . . . . . . . . . 3-6 15.5 TDBCtrlGrid at design time . . . . . . . 15-27
3.2 Objects, components, and controls. . . . . 3-12 15.6 Buttons on the TDBNavigator
3.3 A simplified hierarchy diagram . . . . . . 3-13 control . . . . . . . . . . . . . . . . . . . 15-28
3.4 Three views of the track bar 16.1 Decision support components at
component . . . . . . . . . . . . . . . . . . 3-33 design time . . . . . . . . . . . . . . . . . 16-2
3.5 A progress bar . . . . . . . . . . . . . . . . 3-42 16.2 One-dimensional crosstab . . . . . . . . . 16-3
6.1 A frame with data-aware controls 16.3 Three-dimensional crosstab . . . . . . . . 16-3
and a data source component . . . . . . . 6-15 16.4 Decision graphs bound to different
6.2 The Action Manager editor.. . . . . . . . . 6-20 decision sources. . . . . . . . . . . . . . 16-14
6.3 Menu terminology. . . . . . . . . . . . . . 6-29 20.1 Components in a BDE-based
6.4 MainMenu and PopupMenu application. . . . . . . . . . . . . . . . . . 20-2
components . . . . . . . . . . . . . . . . . 6-30 25.1 Web-based multi-tiered database
6.5 Menu Designer for a pop-up menu . . . . 6-31 application. . . . . . . . . . . . . . . . . 25-31
6.6 Menu Designer for a main menu . . . . . 6-31 27.1 Parts of a Uniform Resource
6.7 Nested menu structures. . . . . . . . . . . 6-34 Locator . . . . . . . . . . . . . . . . . . . . 27-3
8.1 Bitmap-dimension dialog box from the 28.1 Structure of a Server Application . . . . . 28-3
BMPDlg unit.. . . . . . . . . . . . . . . . . 8-20 29.1 Generating Content Flow . . . . . . . . 29-14
12.1 TListBox set to bdLeftToRight . . . . . . . 12-7 29.2 Action request and response . . . . . . 29-16
12.2 TListBox set to bdRightToLeft . . . . . . . 12-7 29.3 Image response to a request . . . . . . . 29-17
12.3 TListBox set to bdRightToLeft- 29.4 Dispatching a page . . . . . . . . . . . . 29-18
NoAlign. . . . . . . . . . . . . . . . . . . . 12-7 33.1 A COM interface . . . . . . . . . . . . . . 33-3
12.4 TListBox set to bdRightToLeft- 33.2 Interface vtable . . . . . . . . . . . . . . . 33-5
ReadingOnly . . . . . . . . . . . . . . . . . 12-7 33.3 In-process server . . . . . . . . . . . . . . 33-7
14.1 Generic Database Architecture . . . . . . . 14-6 33.4 Out-of-process and remote servers . . . . 33-8
14.2 Connecting directly to the database 33.5 COM-based technologies . . . . . . . . .33-11
server . . . . . . . . . . . . . . . . . . . . . 14-8 33.6 Simple COM object interface . . . . . . 33-18
14.3 A file-based database application . . . . . 14-9 33.7 Automation object interface . . . . . . . 33-19
14.4 Architecture combining a client 33.8 ActiveX object interface . . . . . . . . . 33-19
dataset and another dataset . . . . . . . 14-12 33.9 Delphi ActiveX framework . . . . . . . 33-21
14.5 Multi-tiered database architecture . . . . 14-13 34.1 Type Library editor . . . . . . . . . . . . . 34-3
15.1 TDBGrid control . . . . . . . . . . . . . . 15-15 34.2 Object list pane . . . . . . . . . . . . . . . 34-5
15.2 TDBGrid control with ObjectView 36.1 Dual interface VTable . . . . . . . . . . 36-13
set to False . . . . . . . . . . . . . . . . . 15-22 38.1 Mask Edit property page in design
15.3 TDBGrid control with Expanded mode . . . . . . . . . . . . . . . . . . . . 38-12
set to False . . . . . . . . . . . . . . . . . 15-23 40.1 Visual Component Library class
15.4 TDBGrid control with Expanded hierarchy. . . . . . . . . . . . . . . . . . . 40-2
set to True. . . . . . . . . . . . . . . . . . 15-23 40.2 Component wizard . . . . . . . . . . . . . 40-9
xxix
xxx
Chapter
1
Introduction
Chapter1
The Developer’s Guide describes intermediate and advanced development topics, such
as building client/server database applications, writing custom components, and
creating Internet Web server applications. It allows you to build applications that
meet many industry-standard specifications such as SOAP, TCP/IP, COM+, and
ActiveX. Many of the advanced features that support Web development, advanced
XML technologies, and database development require components or wizards that
are not available in all versions of Delphi.
The Developer’s Guide assumes you are familiar with using Delphi and understand
fundamental Delphi programming techniques. For an introduction to Delphi
programming and the integrated development environment (IDE), see the Quick
Start manual or the online Help.
Introduction 1-1
What’s in this manual?
Manual conventions
This manual uses the typefaces and symbols described in Table 1.1 to indicate special
text.
Introduction 1-3
1-4 Developer’s Guide
Part
I
Programming with Delphi
Part I
The chapters in “Programming with Delphi” introduce concepts and skills necessary
for creating Delphi applications using any edition of the product. They also introduce
the concepts discussed in later sections of the Developer’s Guide.
form designer), to the Object Inspector to edit the initial runtime state of the object, to
the source code editor to edit the execution logic of the object. Changing code-related
properties, such as the name of an event handler, in the Object Inspector
automatically changes the corresponding source code. In addition, changes to the
source code, such as renaming an event handler method in a form class declaration,
is immediately reflected in the Object Inspector.
The IDE supports application development throughout the stages of the product life
cycle—from design to deployment. Using the tools in the IDE allows for rapid
prototyping and shortens development time.
A more complete overview of the development environment is presented in the
Quick Start manual included with the product. In addition, the online Help system
provides help on all menus, dialogs, and windows.
Designing applications
Delphi includes all the tools necessary to start designing applications:
• A blank window, known as a form, on which to design the UI for your application.
• Extensive class libraries with many reusable objects.
• An Object Inspector for examining and changing object traits.
• A Code editor that provides direct access to the underlying program logic.
• A Project Manager for managing the files that make up one or more projects.
• Many other tools such as an image editor on the toolbar and an integrated
debugger on menus to support application development in the IDE.
• Command-line tools including compilers, linkers, and other utilities.
You can use Delphi to design any kind of 32-bit application—from general-purpose
utilities to sophisticated data access programs or distributed applications. Delphi’s
database tools and data-aware components let you quickly develop powerful
desktop database and client/server applications. Using Delphi’s data-aware controls,
you can view live data while you design your application and immediately see the
results of database queries and changes to the application interface.
Chapter 5, “Building applications, components, and libraries” introduces Delphi’s
support for different types of applications.
Many of the objects provided in the class library are accessible in the IDE from the
Component palette. The Component palette shows all of the controls, both visual and
nonvisual, that you can place on a form. Each tab contains components grouped by
functionality. By convention, the names of objects in the class library begin with a T,
such as TStatusBar.
One of the revolutionary things about Delphi is that you can create your own
components using Object Pascal. Most of the components provided are written in
Object Pascal. You can add components that you write to the Component palette and
customize the palette for your use by including new tabs if needed.
You can also use Delphi for cross platform development on both Linux and Windows
by using CLX. CLX contains a set of classes that, if used instead of those in the VCL,
allow your program to port between Windows and Linux.
Developing applications
As you visually design the user interface for your application, Delphi generates the
underlying Object Pascal code to support the application. As you select and modify
the properties of components and forms, the results of those changes appear
automatically in the source code, and vice versa. You can modify the source files
directly with any text editor, including the built-in Code editor. The changes you
make are immediately reflected in the visual environment as well.
Creating projects
All of Delphi’s application development revolves around projects. When you create
an application in Delphi you are creating a project. A project is a collection of files
that make up an application. Some of these files are created at design time. Others are
generated automatically when you compile the project source code.
You can view the contents of a project in a project management tool called the Project
Manager. The Project Manager lists, in a hierarchical view, the unit names, the forms
contained in the unit (if there is one), and shows the paths to the files in the project.
Although you can edit many of these files directly, it is often easier and more reliable
to use the visual tools in Delphi.
At the top of the project hierarchy, is a group file. You can combine multiple projects
into a project group. This allows you to open more than one project at a time in the
Project Manager. Project groups let you organize and work on related projects, such
as applications that function together or parts of a multi-tiered application. If you are
only working on one project, you do not need a project group file to create an
application.
Project files, which describe individual projects, files, and associated options, have a
.dpr extension. Project files contain directions for building an application or shared
object. When you add and remove files using the Project Manager, the project file is
updated. You specify project options using a Project Options dialog which has tabs
for various aspects of your project such as forms, application, compiler. These project
options are stored in the project file with the project.
Units and forms are the basic building blocks of a Delphi application. A project can
share any existing form and unit file including those that reside outside the project
directory tree. This includes custom procedures and functions that have been written
as standalone routines.
If you add a shared file to a project, realize that the file is not copied into the current
project directory; it remains in its current location. Adding the shared file to the
current project registers the file name and path in the uses clause of the project file.
Delphi automatically handles this as you add units to a project.
When you compile a project, it does not matter where the files that make up the
project reside. The compiler treats shared files the same as those created by the
project itself.
Editing code
The Delphi Code editor is a full-featured ASCII editor. If using the visual
programming environment, a form is automatically displayed as part of a new
project. You can start designing your application interface by placing objects on the
form and modifying how they work in the Object Inspector. But other programming
tasks, such as writing event handlers for objects, must be done by typing the code.
The contents of the form, all of its properties, its components, and their properties
can be viewed and edited as text in the Code editor. You can adjust the generated
code in the Code editor and add more components within the editor by typing code.
As you type code into the editor, the compiler is constantly scanning for changed and
updating the form with the new layout. You can then go back to the form, view and
test the changes you made in the editor and continue adjusting the form from there.
The Delphi code generation and property streaming systems are completely open to
inspection. The source code for everything that is included in your final executable
file—all of the VCL objects, CLX objects, RTL sources, all of the Delphi project files
can be viewed and edited in the Code editor.
Compiling applications
When you have finished designing your application interface on the form, writing
additional code so it does what you want, you can compile the project from the IDE
or from the command line.
All projects have as a target a single distributable executable file. You can view or test
your application at various stages of development by compiling, building, or
running it:
• When you compile, only units that have changed since the last compile are
recompiled.
• When you build, all units in the project are compiled, regardless of whether or not
they have changed since the last compile. This technique is useful when you are
unsure of exactly which files have or have not been changed, or when you simply
want to ensure that all files are current and synchronized. It's also important to use
Build when you've changed global compiler directives, to ensure that all code
compiles in the proper state. You can also test the validity of your source code
without attempting to compile the project.
• When you run, you compile and then execute your application. If you modified
the source code since the last compilation, the compiler recompiles those changed
modules and relinks your application.
If you have grouped several projects together, you can compile or build all projects in
a single project group at once. Choose Project|Compile All Projects or Project|Build
All Projects with the project group selected in the Project Manager.
Debugging applications
Delphi provides an integrated debugger that helps you find and fix errors in your
applications. The integrated debugger lets you control program execution, monitor
variable values and items in data structures, and modify data values while
debugging.
The integrated debugger can track down both runtime errors and logic errors. By
running to specific program locations and viewing the values of variables, the
functions on the call stack, and the program output, you can monitor how your
program behaves and find the areas where it is not behaving as designed. The
debugger is described in online Help.
You can also use exception handling to recognize, locate, and deal with errors.
Exceptions in Delphi are classes, like other classes in Delphi, except, by convention,
they begin with an E rather than the initial T for other classes.
Deploying applications
Delphi includes add-on tools to help with application deployment. For example,
InstallShield Express (not available in all versions) helps you to create an installation
package for your application that includes all of the files needed for running a
distributed application. Refer to Chapter 13, “Deploying applications” for specific
information on deployment.
Note Not all versions of Delphi have deployment capabilities.
TeamSource software (not available in all versions) is also available for tracking
application updates.
Properties
Properties are characteristics of an object that influence either the visible behavior or
the operations of the object. For example, the Visible property determines whether an
object can be seen or not in an application interface. Well-designed properties make
your components easier for others to use and easier for you to maintain.
Here are some of the useful features of properties:
• Unlike methods, which are only available at runtime, you can see and change
properties at design time and get immediate feedback as the components change
in the IDE.
• Properties can be accessed in the Object Inspector where you can modify the
values of your object visually. Setting properties at design time is easier than
writing code and makes your code easier to maintain.
• Because the data is encapsulated, it is protected and private to the actual object.
• The actual calls to get and set the values are methods, so special processing can be
done that is invisible to the user of the object. For example, data could reside in a
table, but could appear as a normal data member to the programmer.
• You can implement logic that triggers events or modifies other data during the
access of the property. For example, changing the value of one property may
require the modification of another. You can make the change in the methods
created for the property.
• Properties can be virtual.
• A property is not restricted to a single object. Changing a one property on one
object could effect several objects. For example, setting the Checked property on a
radio button effects all of the radio buttons in the group.
Methods
A method is a procedure that is always associated with a class. Methods define the
behavior of an object. Class methods can access all the public, protected, and private
properties and data members of the class and are commonly referred to as member
functions.
Events
An event is an action or occurrence detected by a program. Most modern applications
are said to be event-driven, because they are designed to respond to events. In a
program, the programmer has no way of predicting the exact sequence of actions a
user will perform next. They may choose a menu item, click a button, or mark some
text. You can write code to handle the events you're interested in, rather than writing
code that always executes in the same restricted order.
Regardless of how an event is called, Delphi looks to see if you have written any code
to handle that event. If you have, that code is executed; otherwise, the default event
handling behavior takes place.
The kinds of events that can occur can be divided into two main categories:
• User events
• System events
Regardless of how the event was called, Delphi looks to see if you have assigned any
code to handle that event. If you have, then that code is executed; otherwise, nothing
is done.
User events
User events are actions that are initiated by the user. Examples of user events are
OnClick (the user clicked the mouse), OnKeyPress (the user pressed a key on the
keyboard), and OnDblClick (the user double-clicked a mouse button). These events
are always tied to a user's actions.
System events
System events are events that the operating system fires for you. For example, the
OnTimer event (the Timer component issues one of these events whenever a
predefined interval has elapsed), the OnCreate event (the component is being
created), the OnPaint event (a component or window needs to be redrawn), and so
on. Usually, system events are not directly initiated by a user action.
What is an object?
An object, or class, is a data type that encapsulates data and operations on data in a
single unit. Before object-oriented programming, data and operations (functions)
were treated as separate elements.
You can begin to understand objects if you understand Object Pascal records or
structures in C. Records are made of up fields that contain data, where each field has
its own type. Records make it easy to refer to a collection of varied data elements.
Objects are also collections of data elements. But objects—unlike records—contain
procedures and functions that operate on their data. These procedures and functions
are called methods.
An object’s data elements are accessed through properties. The properties of VCL and
CLX objects have values that you can change at design time without writing code. If
you want a property value to change at runtime, you need to write only a small
amount of code.
The combination of data and functionality in a single unit is called encapsulation. In
addition to encapsulation, object-oriented programming is characterized by
inheritance and polymorphism. Inheritance means that objects derive functionality from
other objects (called ancestors); objects can modify their inherited behavior.
Polymorphism means that different objects derived from the same ancestor support
the same method and property interfaces, which often can be called interchangeably.
fields or methods, because you haven’t added to the form any components (the fields
of the new object) and you haven’t created any event handlers (the methods of the
new object). TForm1 does contain inherited fields and methods, even though you
don’t see them in the type declaration.
This variable declaration declares a variable named Form1 of the new type TForm1.
var
Form1: TForm1;
Form1 represents an instance, or object, of the class type TForm1. You can declare
more than one instance of a class type; you might want to do this, for example, to
create multiple child windows in a Multiple Document Interface (MDI) application.
Each instance maintains its own data, but all instances use the same code to execute
methods.
Although you haven’t added any components to the form or written any code, you
already have a complete Delphi application that you can compile and run. All it does
is display a blank form.
Suppose you add a button component to this form and write an OnClick event
handler that changes the color of the form when the user clicks the button. The result
might look like this:
Figure 3.1 A simple form
When the user clicks the button, the form’s color changes to green. This is the event-
handler code for the button’s OnClick event:
procedure TForm1.Button1Click(Sender: TObject);
begin
Form1.Color := clGreen;
end;
Objects can contain other objects as data fields. Each time you place a component on
a form, a new field appears in the form’s type declaration. If you create the
application described above and look at the code in the Code editor, this is what you
see:
unit Unit1;
interface
uses Windows, Classes, Graphics, Forms, Controls;
type
TForm1 = class(TForm)
Button1: TButton;{ New data field }
procedure Button1Click(Sender: TObject);{ New method declaration }
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);{ The code of the new method }
begin
Form1.Color := clGreen;
end;
end.
TForm1 has a Button1 field that corresponds to the button you added to the form.
TButton is a class type, so Button1 refers to an object.
All the event handlers you write in Delphi are methods of the form object. Each time
you create an event handler, a method is declared in the form object type. The
TForm1 type now contains a new method, the Button1Click procedure, declared
within the TForm1 type declaration. The code that implements the Button1Click
method appears in the implementation part of the unit.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
ebookbell.com