delphi 7 - developer's guide.pdf

1113
Developer’s Guide Borland Software Corporation 100 Enterprise Way, Scotts Valley, CA 95066-3249 www.borland.com Borland ® Delphi 7 for Windows

Upload: luss4u

Post on 13-Apr-2015

477 views

Category:

Documents


23 download

DESCRIPTION

delphi

TRANSCRIPT

Developers Guide

Borland

Delphi 7for WindowsBorland Software Corporation 100 Enterprise Way, Scotts Valley, CA 95066-3249 www.borland.com

Refer to the DEPLOY document located in the root directory of your Delphi 7 product for a complete list of files that you can distribute in accordance with the Delphi 7 License Statement and Limited Warranty. Borland Software Corporation may have patents and/or pending patent applications covering subject matter in this document. Please refer to the product CD or the About dialog box for the list of applicable patents. The furnishing of this document does not give you any license to these patents. COPYRIGHT 19832002 Borland Software Corporation. All rights reserved. All Borland brand and product names are trademarks or registered trademarks of Borland Software Corporation in the United States and other countries. All other marks are the property of their respective owners. Printed in the U.S.A. HDE1370WW21001 7E5R0802 0203040506-9 8 7 6 5 4 3 2 1 D3

ContentsChapter 1

Introduction

1-1

Whats in this manual? . . . . . . . . . . . . . . 1-1 Manual conventions . . . . . . . . . . . . . . . . 1-2 Developer support services . . . . . . . . . . . . 1-3

Part I

Programming with DelphiChapter 2

Developing applications with Delphi 2-1Integrated development environment . Designing applications . . . . . . . . . Creating projects . . . . . . . . . . . . . Editing code . . . . . . . . . . . . . . . Compiling applications . . . . . . . . . Debugging applications . . . . . . . . . Deploying applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 2-2 2-3 2-4 2-4 2-5 2-5

Chapter 3

Using object variables . . . . . . . . . . . Creating, instantiating, and destroying objects . . . . . . . . . . . . . . . . . . . Components and ownership . . . . . . Defining new classes . . . . . . . . . . . . Using interfaces . . . . . . . . . . . . . . . Using interfaces across the hierarchy . Using interfaces with procedures . . . Implementing IInterface . . . . . . . . TInterfacedObject . . . . . . . . . . . . Using the as operator with interfaces . Reusing code and delegation. . . . . . Using implements for delegation . Aggregation . . . . . . . . . . . . . Memory management of interface objects. . . . . . . . . . . . . . . . . . Using reference counting . . . . . Not using reference counting . . . Using interfaces in distributed applications . . . . . . . . . . . . . .

. . . 4-7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8 4-9 4-9 4-12 4-13 4-14 4-14 4-15 4-16 4-16 4-17 4-18

. . . 4-18 . . . 4-19 . . . 4-20 . . . 4-21

Using the component libraryUnderstanding the component library . . Properties, methods, and events . . . . Properties . . . . . . . . . . . . . . . Methods . . . . . . . . . . . . . . . Events . . . . . . . . . . . . . . . . . User events . . . . . . . . . . . . . . System events . . . . . . . . . . . . Internal events . . . . . . . . . . . . Objects, components, and controls . . . . . TObject branch . . . . . . . . . . . . . . TPersistent branch . . . . . . . . . . . . TComponent branch . . . . . . . . . . . TControl branch . . . . . . . . . . . . . TWinControl/TWidgetControl branch . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-1. 3-1 . 3-3 . 3-3 . 3-4 . 3-4 . 3-4 . 3-4 . 3-4 . 3-5 . 3-6 . 3-7 . 3-7 . 3-9 . 3-10

Chapter 5

Using BaseCLXUsing streams . . . . . . . . . . . . . . . . . Using streams to read or write data . . . Stream methods for reading and writing . . . . . . . . . . . . . Reading and writing components . Reading and writing strings . . . . . Copying data from one stream to another. . . . . . . . . . . . . . . . . Specifying the stream position and size. Seeking to a specific position . . . . Using Position and Size properties . Working with files . . . . . . . . . . . . . . Approaches to file I/O . . . . . . . . . . Using file streams . . . . . . . . . . . . . Creating and opening files using file streams . . . . . . . . . . . . . Using the file handle . . . . . . . . . Manipulating files . . . . . . . . . . . . . Deleting a file . . . . . . . . . . . . . Finding a file . . . . . . . . . . . . . Renaming a file . . . . . . . . . . . . File date-time routines . . . . . . . . Copying a file . . . . . . . . . . . . .

5-1. . 5-2 . . 5-2 . . 5-2 . . 5-3 . . 5-3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 5-4 5-4 5-5 5-5 5-6 5-6 5-7 5-8 5-8 5-8 5-8 5-10 5-10 5-11

Chapter 4

Using the object modelWhat is an object? . . . . . . . . . . . . . . . Examining a Delphi object . . . . . . . . Changing the name of a component . . . Inheriting data and code from an object. . . Scope and qualifiers . . . . . . . . . . . . . . Private, protected, public, and published declarations . . . . . . . . . . . . . . . . . . . . . . . . . .

4-14-1 4-2 4-4 4-5 4-5

. . 4-6 iii

Working with ini files and the system Registry . . . . . . . . . . . . . . . . . . Using TIniFile and TMemIniFile . Using TRegistryIniFile . . . . . . Using TRegistry . . . . . . . . . . Working with lists . . . . . . . . . . . . . Common list operations . . . . . . . . Adding list items . . . . . . . . . Deleting list items . . . . . . . . . Accessing list items . . . . . . . . Rearranging list items . . . . . . . Persistent lists. . . . . . . . . . . . . . Working with string lists . . . . . . . . . Loading and saving string lists . . . . Creating a new string list . . . . . . . Short-term string lists . . . . . . . Long-term string lists . . . . . . . Manipulating strings in a list . . . . . Counting the strings in a list . . . Accessing a particular string . . . Locating items in a string list . . . Iterating through strings in a list . Adding a string to a list . . . . . . Moving a string within a list . . . Deleting a string from a list . . . . Associating objects with a string list . . . . . . . . . . . . . Working with strings . . . . . . . . . . . Wide character routines . . . . . . . . Commonly used long string routines Commonly used routines for null-terminated strings. . . . . . . . Declaring and initializing strings . . . Mixing and converting string types . String to PChar conversions. . . . . . String dependencies . . . . . . . . Returning a PChar local variable Passing a local variable as a PChar . . . . . . . . . . . . . . Compiler directives for strings . . . . Creating drawing spaces . . . . . . . . . Printing . . . . . . . . . . . . . . . . . . . Converting measurements . . . . . . . . Performing conversions . . . . . . . . Performing simple conversions . Performing complex conversions Adding new measurement types . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5-11 5-12 5-13 5-13 5-14 5-15 5-15 5-15 5-16 5-16 5-16 5-17 5-17 5-18 5-18 5-18 5-20 5-20 5-20 5-20 5-20 5-21 5-21 5-21 5-22 5-22 5-22 5-23 5-26 5-27 5-28 5-28 5-29 5-29 5-29 5-30 5-31 5-32 5-33 5-33 5-33 5-33 5-34

Creating a simple conversion family and adding units. . . . . . . . . . . . Declare variables . . . . . . . . . . Register the conversion family . . Register measurement units . . . . Use the new units . . . . . . . . . . Using a conversion function . . . . . . Declare variables . . . . . . . . . . Register the conversion family . . Register the base unit . . . . . . . Write methods to convert to and from the base unit . . . . . . . . . Register the other units . . . . . . Use the new units . . . . . . . . . . Using a class to manage conversions . Creating the conversion class . . . Declare variables . . . . . . . . . . Register the conversion family and the other units . . . . . . . . . . . Use the new units . . . . . . . . . . Defining custom variants . . . . . . . . . Storing a custom variant types data . Creating a class to enable the custom variant type . . . . . . . . . . Enabling casting . . . . . . . . . . Implementing binary operations . Implementing comparison operations . . . . . . . . . . . . . Implementing unary operations . Copying and clearing custom variants Loading and saving custom variant values . . . . . . . . . . . Using the TCustomVariantType descendant . . . . . . . . . . . . . Writing utilities to work with a custom variant type . . . . . . . . . . Supporting properties and methods in custom variants . . . . . . . . . . . Using TInvokeableVariantType . . Using TPublishableVariantType .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

5-34 5-35 5-35 5-35 5-35 5-36 5-36 5-36 5-36 5-36 5-37 5-37 5-37 5-38 5-39 5-39 5-40 5-40 5-41

. . . 5-42 . . . 5-42 . . . 5-44 . . . 5-46 . . . 5-47 . . . 5-48 . . . 5-49 . . . 5-50 . . . 5-50 . . . 5-51 . . . 5-51 . . . 5-53

Chapter 6

Working with componentsSetting component properties . . . . Setting properties at design time Using property editors . . . . Setting properties at runtime. . . Calling methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6-16-2 6-2 6-3 6-3 6-3

iv

Working with events and event handlers . Generating a new event handler . . . . Generating a handler for a components default event . . . . . . Locating event handlers . . . . . . . . . Associating an event with an existing event handler . . . . . . . . . . . . . . Using the Sender parameter . . . . Displaying and coding shared events . . . . . . . . . . . . . . . . Associating menu events with event handlers . . . . . . . . . . . . . Deleting event handlers . . . . . . . . . Cross-platform and non-cross-platform components . . . . . . . . . . . . . . . . . Adding custom components to the Component palette . . . . . . . . . . .

. . . 6-3 . . . 6-4 . . . 6-4 . . . 6-4 . . . 6-5 . . . 6-5 . . . 6-5 . . . 6-6 . . . 6-6 . . . 6-7 . . . 6-9

Adding graphics to controls . . . . . . . Indicating that a control is owner-drawn. . . . . . . . . . . . . Adding graphical objects to a string list . . . . . . . . . . . . . . Adding images to an application Adding images to a string list . . Drawing owner-drawn items . . Sizing owner-draw items . . . . . . . Drawing owner-draw items . . . . .

. . . . 7-13 . . . . 7-13 . . . . . . . . . . . . . . . . . . . . . . . . 7-14 7-14 7-14 7-15 7-16 7-17

Chapter 8

Building applications, components, and libraries 8-1Creating applications . . . . . . . . . . . . GUI applications. . . . . . . . . . . . . User interface models . . . . . . . SDI applications . . . . . . . . . . MDI applications . . . . . . . . . . Setting IDE, project, and compiler options . . . . . . . . . . . . . . . Programming templates . . . . . . . . Console applications . . . . . . . . . . Service applications . . . . . . . . . . . Service threads . . . . . . . . . . . Service name properties . . . . . . Debugging service applications . . Creating packages and DLLs . . . . . . . When to use packages and DLLs . . . Writing database applications . . . . . . . Distributing database applications . . Creating Web server applications . . . . . Creating Web Broker applications . . . Creating WebSnap applications . . . . Creating Web Services applications . . Writing applications using COM . . . . . Using COM and DCOM . . . . . . . . Using MTS and COM+ . . . . . . . . . Using data modules . . . . . . . . . . . . Creating and editing standard data modules. . . . . . . . . . . . . . . . . Naming a data module and its unit file . . . . . . . . . . . . . Placing and naming components . Using component properties and events in a data module . . . . . Creating business rules in a data module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1 8-2 8-2 8-2 8-2 8-3 8-3 8-4 8-5 8-8 8-9 8-10 8-11 8-11 8-12 8-13 8-13 8-14 8-15 8-15 8-16 8-16 8-16 8-17

Chapter 7

Working with controlsImplementing drag and drop in controls . . Starting a drag operation . . . . . . . . . Accepting dragged items . . . . . . . . . Dropping items . . . . . . . . . . . . . . . Ending a drag operation. . . . . . . . . . Customizing drag and drop with a drag object. . . . . . . . . . . . . . . . Changing the drag mouse pointer . . . . Implementing drag and dock in controls . . Making a windowed control a docking site . . . . . . . . . . . . . . . . Making a control a dockable child . . . . Controlling how child controls are docked . . . . . . . . . . . . . . . . . Controlling how child controls are undocked . . . . . . . . . . . . . . . Controlling how child controls respond to drag-and-dock operations . . . . . . Working with text in controls. . . . . . . . . Setting text alignment . . . . . . . . . . . Adding scroll bars at runtime . . . . . . . Adding the clipboard object. . . . . . . . Selecting text . . . . . . . . . . . . . . . . Selecting all text . . . . . . . . . . . . . . Cutting, copying, and pasting text . . . . Deleting selected text . . . . . . . . . . . Disabling menu items . . . . . . . . . . . Providing a pop-up menu . . . . . . . . . Handling the OnPopup event. . . . . . . . . . . . . . . . .

7-17-1 7-1 7-2 7-3 7-3

. . 7-3 . . 7-4 . . 7-4 . . 7-4 . . 7-5 . . 7-5 . . 7-6 . . . . . . . . . . . . . . . . . . . 7-6 7-6 7-7 7-7 7-8 7-9 7-9 7-10 7-10 7-11 7-11 7-12

. . . 8-17 . . . 8-18 . . . 8-19 . . . 8-19 . . . 8-20

v

Accessing a data module from a form . Adding a remote data module to an application server project . . . . . . . Using the Object Repository . . . . . . . . Sharing items within a project . . . . . Adding items to the Object Repository . . . . . . . . . . . . . . . . Sharing objects in a team environment. . . . . . . . . . . . . . . Using an Object Repository item in a project . . . . . . . . . . . . . . . . . Copying an item . . . . . . . . . . . Inheriting an item . . . . . . . . . . Using an item . . . . . . . . . . . . Using project templates . . . . . . . . . Modifying shared items . . . . . . . . . Specifying a default project, new form, and main form . . . . . . . . . . . . . Enabling Help in applications . . . . . . . Help system interfaces . . . . . . . . . . Implementing ICustomHelpViewer . . Communicating with the Help Manager . . . . . . . . . . . . . . . . . Asking the Help Manager for information . . . . . . . . . . . . . . . Displaying keyword-based Help . . . . Displaying tables of contents . . . . . . Implementing IExtendedHelpViewer . Implementing IHelpSelector . . . . . . Registering Help system objects . . . . Registering Help viewers . . . . . . Registering Help selectors . . . . . Using Help in a VCL application. . . . . . How TApplication processes VCL Help . . . . . . . . . . . . . . . . How VCL controls process Help . . . . Using Help in a CLX application. . . . . . How TApplication processes CLX Help . . . . . . . . . . . . . . . . How CLX controls process Help . . . . Calling a Help system directly . . . . . . . Using IHelpSystem . . . . . . . . . . . . . Customizing the IDE Help system . . . . .

. . 8-20 . . 8-21 . . 8-21 . . 8-21 . . 8-22 . . 8-22 . . . . . . . . . . . . . . . . . . . . 8-22 8-22 8-23 8-23 8-23 8-23 8-24 8-24 8-25 8-25

Chapter 9

Developing the application user interfaceControlling application behavior . . . . . . Working at the application level . . . . . Handling the screen . . . . . . . . . . . . Setting up forms. . . . . . . . . . . . . . . . Using the main form . . . . . . . . . . . Hiding the main form. . . . . . . . . . . Adding forms . . . . . . . . . . . . . . . Linking forms . . . . . . . . . . . . . Avoiding circular unit references . . Managing layout . . . . . . . . . . . . . Using forms . . . . . . . . . . . . . . . . . . Controlling when forms reside in memory . . . . . . . . . . . . . . . . Displaying an auto-created form . . Creating forms dynamically . . . . . Creating modeless forms such as windows . . . . . . . . . . . . . Creating a form instance using a local variable . . . . . . . . . . . Passing additional arguments to forms . Retrieving data from forms. . . . . . . . Retrieving data from modeless forms . . . . . . . . . . . . . . . . . Retrieving data from modal forms . Reusing components and groups of components . . . . . . . . . . . . . . . . . Creating and using component templates . . . . . . . . . . . . . . . . . . . Working with frames . . . . . . . . . . . . . Creating frames . . . . . . . . . . . . . . Adding frames to the Component palette . . . . . . . . . . . . . . . . . . . Using and modifying frames. . . . . . . Sharing frames. . . . . . . . . . . . . . . Developing dialog boxes . . . . . . . . . . . Using open dialog boxes . . . . . . . . . Organizing actions for toolbars and menus . . . . . . . . . . . . . . . . . . What is an action? . . . . . . . . . . . . . Setting up action bands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

9-19-1 9-2 9-2 9-3 9-3 9-3 9-4 9-4 9-4 9-5 9-6

. . 9-6 . . 9-6 . . 9-7 . . 9-8 . . 9-8 . . 9-8 . . 9-9 . . 9-9 . . 9-11 . . 9-13 . . 9-13 . . 9-14 . . 9-14 . . . . . . . . . . 9-15 9-15 9-16 9-17 9-17

. . 8-26 . . . . . . . . . . . . . . . . . . 8-26 8-27 8-28 8-28 8-29 8-30 8-30 8-30 8-31

. . 8-31 . . 8-31 . . 8-32 . . . . . . . . . . 8-32 8-32 8-33 8-33 8-34

. . 9-18 . . 9-19 . . 9-20

vi

Creating toolbars and menus . . . . . . Adding color, patterns, or pictures to menus, buttons, and toolbars . Adding icons to menus and toolbars . . . . . . . . . . . . . . . Selecting menu and toolbar styles . Creating dynamic menus . . . . . . Creating toolbars and menus that users can customize . . . . . . . . Hiding unused items and categories in action bands . . . . . . . . . . . Creating most recently used (MRU) lists . . . . . . . . . . . . . Using action lists . . . . . . . . . . . . . . . Setting up action lists . . . . . . . . . . What happens when an action fires . . Responding with events . . . . . . How actions find their targets . . . Updating actions . . . . . . . . . . . . . Predefined action classes . . . . . . . . Writing action components . . . . . . . Registering actions . . . . . . . . . . . . Creating and managing menus. . . . . . . Opening the Menu Designer . . . . . . Building menus . . . . . . . . . . . . . . Naming menus . . . . . . . . . . . Naming the menu items . . . . . . Adding, inserting, and deleting menu items . . . . . . . . . . . . . Adding separator bars . . . . . . . Specifying accelerator keys and keyboard shortcuts . . . . . . . . Creating submenus. . . . . . . . . . . . Creating submenus by demoting existing menus . . . . . . . . . . . Moving menu items . . . . . . . . . Adding images to menu items . . . Viewing the menu . . . . . . . . . . Editing menu items in the Object Inspector . . . . . . . . . . . . . . . . . Using the Menu Designer context menu . . . . . . . . . . . . . . . . . . . Commands on the context menu . Switching between menus at design time . . . . . . . . . . . . . Using menu templates . . . . . . . . . . Saving a menu as a template . . . . . . Naming conventions for template menu items and event handlers .

. . 9-20 . . 9-22 . . 9-22 . . 9-23 . . 9-24 . . 9-24 . . 9-24 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-25 9-26 9-26 9-27 9-27 9-29 9-29 9-30 9-31 9-31 9-32 9-33 9-34 9-34 9-34

. . 9-35 . . 9-36 . . 9-36 . . 9-37 . . . . . . . . 9-37 9-38 9-38 9-39

Manipulating menu items at runtime . . . . Merging menus . . . . . . . . . . . . . . . . Specifying the active menu: Menu property . . . . . . . . . . . . . . . . . Determining the order of merged menu items: GroupIndex property . . . . . . Importing resource files . . . . . . . . . . . Designing toolbars and cool bars . . . . . . . . Adding a toolbar using a panel component . . . . . . . . . . . . . . . . . . Adding a speed button to a panel . . . Assigning a speed buttons glyph . . . Setting the initial condition of a speed button . . . . . . . . . . . . . . . Creating a group of speed buttons . . . Allowing toggle buttons . . . . . . . . . Adding a toolbar using the toolbar component . . . . . . . . . . . . . . . . . . Adding a tool button . . . . . . . . . . . Assigning images to tool buttons . . . . Setting tool button appearance and initial conditions . . . . . . . . . . . . Creating groups of tool buttons . . . . . Allowing toggled tool buttons . . . . . Adding a cool bar component . . . . . . . . Setting the appearance of the cool bar . . . . . . . . . . . . . . . . . . Responding to clicks . . . . . . . . . . . . . Assigning a menu to a tool button . . . Adding hidden toolbars . . . . . . . . . . . Hiding and showing toolbars . . . . . . . . Demo programs . . . . . . . . . . . . . . . . Common controls and XP themes. . . . . . . .

9-44 9-44 9-45 9-45 9-45 9-46 9-47 9-47 9-48 9-48 9-48 9-49 9-49 9-49 9-50 9-50 9-51 9-51 9-51 9-52 9-52 9-52 9-53 9-53 9-53 9-54

Chapter 10

Types of controlsText controls . . . . . . . . . . . . . Edit controls . . . . . . . . . . . Memo and rich edit controls Text viewing controls . . . . . . Labels . . . . . . . . . . . . . . . Specialized input controls . . . . . Scroll bars . . . . . . . . . . . . Track bars. . . . . . . . . . . . . Up-down controls . . . . . . . . Spin edit controls (CLX only) . Hot key controls (VCL only) . . Splitter controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

10-1. . . . . . . . . . . . 10-1 10-1 10-2 10-3 10-3 10-4 10-4 10-5 10-5 10-5 10-6 10-6

. . 9-39 . . 9-40 . . 9-40 . . 9-41 . . 9-41 . . 9-43 . . 9-44

vii

Buttons and similar controls . . . Button controls . . . . . . . . . Bitmap buttons . . . . . . . . . Speed buttons. . . . . . . . . . Check boxes . . . . . . . . . . . Radio buttons . . . . . . . . . . Toolbars . . . . . . . . . . . . . Cool bars (VCL only). . . . . . List controls. . . . . . . . . . . . . List boxes and check-list boxes Combo boxes . . . . . . . . . . Tree views . . . . . . . . . . . . List views . . . . . . . . . . . . Icon views (CLX only) . . . . . Date-time pickers and month calendars. . . . . . . . . . . . Grouping controls . . . . . . . . . Group boxes and radio groups Panels . . . . . . . . . . . . . . Scroll boxes . . . . . . . . . . . Tab controls . . . . . . . . . . . Page controls . . . . . . . . . . Header controls. . . . . . . . . Display controls . . . . . . . . . . Status bars. . . . . . . . . . . . Progress bars . . . . . . . . . . Help and hint properties . . . Grids. . . . . . . . . . . . . . . . . Draw grids . . . . . . . . . . . String grids . . . . . . . . . . . Value list editors (VCL only) . . . Graphic controls . . . . . . . . . . Images . . . . . . . . . . . . . . Shapes . . . . . . . . . . . . . . Bevels . . . . . . . . . . . . . . Paint boxes . . . . . . . . . . . Animation control . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

10-6 10-7 10-7 10-8 10-8 10-8 10-9 10-9 10-9 10-10 10-11 10-11 10-12 10-12 10-12 10-12 10-13 10-13 10-13 10-14 10-14 10-14 10-15 10-15 10-15 10-16 10-16 10-16 10-16 10-17 10-18 10-18 10-18 10-18 10-19 10-19

Using ModelMaker views . . Collections pane . . . . . . Classes view . . . . . . Units view . . . . . . . Diagrams view . . . . Members pane . . . . . . . Editors pane . . . . . . . . Implementation Editor Unit Code Editor . . . Diagram Editor . . . . Other Editors . . . . . For more information. . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . .

11-4 11-5 11-5 11-5 11-6 11-7 11-7 11-7 11-8 11-9 11-9 11-10

Chapter 12

Working with graphics and multimediaOverview of graphics programming . . Refreshing the screen . . . . . . . . . Types of graphic objects . . . . . . . Common properties and methods of Canvas . . . . . . . . . . . . . . . Using the properties of the Canvas object . . . . . . . . . . . . . . . . . Using pens . . . . . . . . . . . . Using brushes . . . . . . . . . . . Reading and setting pixels . . . Using Canvas methods to draw graphic objects . . . . . . . . . . . . Drawing lines and polylines . . Drawing shapes . . . . . . . . . . Handling multiple drawing objects in your application . . . . . . . . . Keeping track of which drawing tool to use . . . . . . . . . . . . Changing the tool with speed buttons . . . . . . . . . . . . . . Using drawing tools . . . . . . . Drawing on a graphic . . . . . . . . . Making scrollable graphics . . . Adding an image control . . . . Loading and saving graphics files . . Loading a picture from a file . . Saving a picture to a file . . . . . Replacing the picture . . . . . . .

12-1. . . . 12-1 . . . . 12-2 . . . . 12-3 . . . . 12-4 . . . . . . . . . . . . . . . . 12-5 12-5 12-8 12-9

. . . 12-10 . . . 12-10 . . . 12-11 . . . 12-12 . . . 12-12 . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-13 12-14 12-16 12-17 12-17 12-19 12-19 12-20 12-20

Chapter 11

Designing classes and components with ModelMakerModelMaker fundamentals . . . . . . ModelMaker models . . . . . . . . Using ModelMaker with the IDE . Creating models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-111-2 11-2 11-2 11-3

viii

Using the clipboard with graphics . . Copying graphics to the clipboard . . . . . . . . . . . . . Cutting graphics to the clipboard Pasting graphics from the clipboard . . . . . . . . . . . . . Rubber banding example . . . . . . . Responding to the mouse . . . . . Responding to a mouse-down action . . . . . . . . . . . . . . . Adding a field to a form object to track mouse actions . . . . . . . Refining line drawing . . . . . . . Working with multimedia . . . . . . . . Adding silent video clips to an application. . . . . . . . . . . . . . . Example of adding silent video clips . . . . . . . . . . . . Adding audio and/or video clips to an application . . . . . . . . . . . . . Example of adding audio and/or video clips (VCL only) . . . . .

. . . 12-21 . . . 12-22 . . . 12-22 . . . 12-23 . . . 12-24 . . . 12-24 . . . 12-25 . . . 12-27 . . . 12-28 . . . 12-30 . . . 12-30 . . . 12-31 . . . 12-32 . . . 12-33

Executing thread objects . . . . . . . . . Overriding the default priority . . . Starting and stopping threads . . . . Debugging multi-threaded applications Naming a thread. . . . . . . . . . . . Converting an unnamed thread to a named thread . . . . . . . Assigning separate names to similar threads . . . . . . . . .

. . . . .

. . . . .

. . . . .

13-12 13-12 13-12 13-13 13-13

. . . 13-13 . . . 13-15

Chapter 14

Exception handlingDefining protected blocks . . . . . . . . Writing the try block . . . . . . . . . Raising an exception . . . . . . . Writing exception handlers. . . . . . Exception-handling statements . Handling classes of exceptions . Scope of exception handlers . . . Reraising exceptions . . . . . . . Writing finally blocks . . . . . . . . . Writing a finally block . . . . . . Handling exceptions in VCL applications . . . . . . . . . . . . . . . VCL exception classes . . . . . . . . Default exception handling in VCL . Silent exceptions. . . . . . . . . . . . Defining your own VCL exceptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

14-1. . . . . . . . . . 14-2 14-2 14-3 14-4 14-4 14-6 14-6 14-7 14-8 14-9

Chapter 13

Writing multi-threaded applications 13-1Defining thread objects . . . . . . . . . . . . Initializing the thread . . . . . . . . . . . Assigning a default priority . . . . . Indicating when threads are freed . . Writing the thread function . . . . . . . . Using the main VCL/CLX thread . . Using thread-local variables . . . . . Checking for termination by other threads . . . . . . . . . . . . . . . . Handling exceptions in the thread function . . . . . . . . . . . . . . . . Writing clean-up code . . . . . . . . . . . Coordinating threads . . . . . . . . . . . . . Avoiding simultaneous access . . . . . . Locking objects . . . . . . . . . . . . Using critical sections . . . . . . . . . Using the multi-read exclusive-write synchronizer . . . . . . . . . . . . . Other techniques for sharing memory . . . . . . . . . . . . . . . . Waiting for other threads . . . . . . . . . Waiting for a thread to finish executing . . . . . . . . . . . . . . . Waiting for a task to be completed . . . . . . . . . . . . . . . . . . . . . 13-2 13-3 13-3 13-4 13-4 13-4 13-6

. 14-9 14-10 14-11 14-12 14-13

Chapter 15

Developing cross-platform applicationsCreating CLX applications . . . . . . . . . Porting VCL applications . . . . . . . . . Porting techniques . . . . . . . . . . . Platform-specific ports . . . . . . . Cross-platform ports . . . . . . . . Windows emulation ports . . . . . Modifying VCL applications . . . . . . WinCLX versus VisualCLX. . . . . . . What VisualCLX does differently . Features that do not port directly or are missing . . . . . . . . . . . . . Comparing WinCLX and VisualCLX units . . . . . . . . . . . . Differences in CLX object constructors Handling system and widget events . . . . . . . . . . . . . . . . . . .

15-1. . . . . . . . . 15-2 15-2 15-2 15-3 15-3 15-3 15-4 15-5 15-6

. 13-6 . . . . . . 13-6 13-7 13-7 13-7 13-8 13-8

. 13-8 . 13-9 . 13-9 . 13-10 . 13-10 ix

. . . 15-7 . . . 15-8 . . 15-11 . . 15-12

Writing portable code . . . . . . . . Using conditional directives . . Terminating conditional directives . . . . . . . . . . . . Including inline assembler code Programming differences on Linux Transferring applications between Windows and Linux . . . . . . . . . . Sharing source files between Windows and Linux . . . . . . . . Environmental differences between Windows and Linux . . . . . . . . Registry . . . . . . . . . . . . . . Look and feel . . . . . . . . . . . Directory structure on Linux . . . . Cross-platform database applications . dbExpress differences . . . . . . . . Component-level differences . . . . User interface-level differences . . . Porting database applications to Linux . . . . . . . . . . . . . . . Updating data in dbExpress applications . . . . . . . . . . . . . Cross-platform Internet applications . Porting Internet applications to Linux . . . . . . . . . . . . . . .

. . . . 15-12 . . . . 15-13 . . . . 15-14 . . . . 15-15 . . . . 15-16 . . . . 15-17 . . . . 15-17 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-18 15-20 15-20 15-20 15-21 15-22 15-22 15-23

Editing package source files manually . . . . . . . . . . . . . . Compiling packages . . . . . . . . Package-specific compiler directives . . . . . . . . . . . . Compiling and linking from the command line . . . . . . . . . Package files created when compiling . . . . . . . . . . . Deploying packages . . . . . . . . . . Deploying applications that use packages . . . . . . . . . . . . . . Distributing packages to other developers . . . . . . . . . . . . . Package collection files . . . . . . .

. . . . 16-10 . . . . 16-10 . . . . 16-11 . . . . 16-13 . . . . 16-13 . . . . 16-14 . . . . 16-14 . . . . 16-14 . . . . 16-14

Chapter 17

Creating international applications 17-1Internationalization and localization . . . . Internationalization . . . . . . . . . . . . Localization . . . . . . . . . . . . . . . . Internationalizing applications . . . . . . . Enabling application code . . . . . . . . ~Character sets . . . . . . . . . . . . OEM and ANSI character sets . . . Multibyte character sets . . . . . . . Wide characters . . . . . . . . . . . . Including bi-directional functionality in applications . . . . . . . . . . . . BiDiMode property . . . . . . . . . . Locale-specific features . . . . . . . Designing the user interface . . . . . . . Text . . . . . . . . . . . . . . . . . . . Graphic images . . . . . . . . . . . . Formats and sort order . . . . . . . . Keyboard mappings . . . . . . . . . Isolating resources. . . . . . . . . . . . . Creating resource DLLs. . . . . . . . . . Using resource DLLs . . . . . . . . . . . Dynamic switching of resource DLLs . . Localizing applications . . . . . . . . . . . . Localizing resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-1 17-1 17-2 17-2 17-2 17-2 17-3 17-3 17-4

. . . . 15-24 . . . . 15-26 . . . . 15-28 . . . . 15-28

Chapter 16

Working with packages and componentsWhy use packages? . . . . . . . . . . . Packages and standard DLLs . . . . Runtime packages . . . . . . . . . . . . Loading packages in an application Loading packages with the LoadPackage function . . . . . . Deciding which runtime packages to use . . . . . . . . . . . . . . . . . Custom packages . . . . . . . . . . . Design-time packages . . . . . . . . . . Installing component packages . . . Creating and editing packages . . . . . Creating a package . . . . . . . . . . Editing an existing package . . . . . Understanding the structure of a package . . . . . . . . . . . . . . Naming packages . . . . . . . . Requires clause . . . . . . . . . Contains clause . . . . . . . . . . . . . . . . . . . . . . . . .

16-116-2 16-2 16-3 16-3

. . . . 16-4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-4 16-5 16-5 16-6 16-7 16-7 16-8 16-8 16-8 16-9 16-9

. 17-4 . 17-4 . 17-7 . 17-7 . 17-7 . 17-8 . 17-8 . 17-8 . 17-8 . 17-9 17-10 17-11 17-12 17-12

x

Chapter 18

Deploying applicationsDeploying general applications . . . . . Using installation programs. . . . . . Identifying application files . . . Application files . . . . . . . . . . Package files . . . . . . . . . . . . Merge modules . . . . . . . . . . ActiveX controls . . . . . . . . . . Helper applications . . . . . . . . DLL locations . . . . . . . . . . . Deploying CLX applications . . . . . . . Deploying database applications. . . . . Deploying dbExpress database applications . . . . . . . . . . . . . . Deploying BDE applications . . . . . Borland Database Engine . . . . . Deploying multi-tiered database applications (DataSnap) . . . . . . . Deploying Web applications . . . . . . . Deploying on Apache servers . . . . Enabling modules . . . . . . . . . CGI applications . . . . . . . . . . Programming for varying host environments . . . . . . . . . . . . . . . Screen resolutions and color depths . Considerations when not dynamically resizing . . . . . . Considerations when dynamically resizing forms and controls . . . Accommodating varying color depths . . . . . . . . . . . Fonts . . . . . . . . . . . . . . . . . . . Operating systems versions . . . . . . Software license requirements . . . . . . DEPLOY . . . . . . . . . . . . . . . . . README . . . . . . . . . . . . . . . . No-nonsense license agreement . . . Third-party product documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

18-118-1 18-2 18-2 18-3 18-3 18-3 18-5 18-5 18-6 18-6 18-6

. . . 18-7 . . . 18-8 . . . 18-8 . . . . . . . . . . . . . . . 18-9 18-9 18-10 18-10 18-11

Transactions . . . . . . . . . . . . . . . . . Referential integrity, stored procedures, and triggers. . . . . . . . . . . . . . . . . Database architecture. . . . . . . . . . . . . . General structure . . . . . . . . . . . . . . The user interface form . . . . . . . . The data module . . . . . . . . . . . . Connecting directly to a database server . . . . . . . . . . . . . . . . . . . . Using a dedicated file on disk . . . . . . . Connecting to another dataset . . . . . . . Connecting a client dataset to another dataset in the same application . . . Using a multi-tiered architecture . . . Combining approaches . . . . . . . . . . . Designing the user interface . . . . . . . . . . Analyzing data . . . . . . . . . . . . . . . Writing reports. . . . . . . . . . . . . . . .

. 19-4 . . . . . 19-5 19-6 19-6 19-6 19-6

. 19-8 . 19-9 19-10 19-12 19-13 19-14 19-15 19-15 19-16

Chapter 20

Using data controlsUsing common data control features . . . . Associating a data control with a dataset . . . . . . . . . . . . . . . . . Changing the associated dataset at runtime . . . . . . . . . . . . . . Enabling and disabling the data source . . . . . . . . . . . . . . . . Responding to changes mediated by the data source . . . . . . . . . Editing and updating data . . . . . . . . Enabling editing in controls on user entry . . . . . . . . . . . . . . Editing data in a control . . . . . . . Disabling and enabling data display . . Refreshing data display. . . . . . . . . . Enabling mouse, keyboard, and timer events . . . . . . . . . . . . . . . Choosing how to organize the data . . . . . Displaying a single record . . . . . . . . Displaying data as labels . . . . . . Displaying and editing fields in an edit box . . . . . . . . . . . . . . Displaying and editing text in a memo control . . . . . . . . . . . . Displaying and editing text in a rich edit memo control . . . . . . . . . Displaying and editing graphics fields in an image control . . . . .

20-1. . 20-2 . . 20-3 . . 20-4 . . 20-4 . . 20-4 . . 20-5 . . . . . . . . . . . . . . . . 20-5 20-5 20-6 20-7 20-7 20-7 20-7 20-8

. . . 18-12 . . . 18-12 . . . 18-12 . . . 18-13 . . . . . . . . . . . . . . . . . . . . . . . . 18-14 18-14 18-15 18-15 18-15 18-16 18-16 18-16

Part II

Developing database applicationsChapter 19

. . 20-8 . . 20-9 . . 20-9 . 20-10

Designing database applications

19-1

Using databases . . . . . . . . . . . . . . . . . 19-1 Types of databases . . . . . . . . . . . . . . 19-2 Database security. . . . . . . . . . . . . . . 19-4

xi

Displaying and editing data in list and combo boxes . . . . . . . . Handling Boolean field values with check boxes . . . . . . . . . Restricting field values with radio controls . . . . . . . . . . . Displaying multiple records. . . . . . Viewing and editing data with TDBGrid Using a grid control in its default state . . . . . . . . . . . . . . . . . . Creating a customized grid . . . . . . Understanding persistent columns . . . . . . . . . . . . . . Creating persistent columns . . . Deleting persistent columns . . . Arranging the order of persistent columns . . . . . . . . . . . . . . Setting column properties at design time . . . . . . . . . . . . Defining a lookup list column . . Putting a button in a column . . . Restoring default values to a column . . . . . . . . . . . . . Displaying ADT and array fields . . . Setting grid options . . . . . . . . . . Editing in the grid . . . . . . . . . . . Controlling grid drawing . . . . . . . Responding to user actions at runtime . . . . . . . . . . . . . . . Creating a grid that contains other data-aware controls . . . . . . . . . . . Navigating and manipulating records. . Choosing navigator buttons to display . . . . . . . . . . . . . . . . . Hiding and showing navigator buttons at design time . . . . . . Hiding and showing navigator buttons at runtime . . . . . . . . Displaying fly-over help. . . . . . . . Using a single navigator for multiple datasets . . . . . . . . . . . . . . . .

. . . 20-10 . . . 20-13 . . . 20-14 . . . 20-14 . . . 20-15 . . . 20-16 . . . 20-17 . . . 20-17 . . . 20-18 . . . 20-19 . . . 20-19 . . . 20-20 . . . 20-21 . . . 20-22 . . . . . . . . . . . . . . . 20-22 20-22 20-24 20-26 20-26

Component overview . . . . . . . . VCL/CLX components . . . . . . Engine components . . . . . Render components . . . . . Data connection components Rave project component . . . Reporting components . . . . . . Project components . . . . . . Data objects . . . . . . . . . . Standard components . . . . Drawing components . . . . Report components . . . . . . Bar code components . . . . Getting more information . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

21-4 21-4 21-4 21-4 21-4 21-5 21-5 21-5 21-5 21-5 21-5 21-6 21-6 21-6

Chapter 22

Using decision support componentsOverview . . . . . . . . . . . . . . . . . . About crosstabs . . . . . . . . . . . . . . . One-dimensional crosstabs. . . . . . . Multidimensional crosstabs . . . . . . Guidelines for using decision support components . . . . . . . . . . . . . . . . Using datasets with decision support components . . . . . . . . . . . . . . . . Creating decision datasets with TQuery or TTable . . . . . . . . . . . Creating decision datasets with the Decision Query editor. . . . . . . . . Using decision cubes . . . . . . . . . . . . Decision cube properties and events . Using the Decision Cube editor . . . . Viewing and changing dimension settings . . . . . . . . . . . . . . . Setting the maximum available dimensions and summaries . . . Viewing and changing design options . . . . . . . . . . . . . . . Using decision sources . . . . . . . . . . . Properties and events . . . . . . . . . . Using decision pivots. . . . . . . . . . . . Decision pivot properties. . . . . . . . Creating and using decision grids . . . . Creating decision grids . . . . . . . . . Using decision grids . . . . . . . . . . Opening and closing decision grid fields . . . . . . . . . . . . . . . . . . . . .

22-1. . . . 22-1 22-2 22-3 22-3

. . . 22-4 . . . 22-5 . . . 22-6 . . . . . . . . . . . . 22-6 22-7 22-7 22-8

. . . 20-27 . . . 20-28 . . . 20-29 . . . 20-30 . . . 20-30 . . . 20-31 . . . 20-31 . . . 20-32

. . . 22-8 . . . 22-9 . . . . . . . . . . . . . . . . . 22-9 . 22-9 . 22-9 22-10 22-10 22-11 22-11 22-11

Chapter 21

Creating reports with Rave Reports 21-1Overview . . . . . . . . . . . . . . . . . . . . . 21-1 Getting started . . . . . . . . . . . . . . . . . . 21-2 The Rave Visual Designer. . . . . . . . . . . . 21-3

. . 22-11

xii

Reorganizing rows and columns in decision grids . . . . . . . . . . . Drilling down for detail in decision grids . . . . . . . . . . . Limiting dimension selection in decision grids . . . . . . . . . . . Decision grid properties . . . . . . . . . Creating and using decision graphs . . . . Creating decision graphs . . . . . . . . Using decision graphs . . . . . . . . . . The decision graph display . . . . . . . Customizing decision graphs . . . . . . Setting decision graph template defaults . . . . . . . . . . . . . . . Customizing decision graph series . . . . . . . . . . . . . . . . Decision support components at runtime . . . . . . . . . . . . . . . . . . . Decision pivots at runtime . . . . . . . Decision grids at runtime . . . . . . . . Decision graphs at runtime . . . . . . . Decision support components and memory control . . . . . . . . . . . . . . Setting maximum dimensions, summaries, and cells . . . . . . . . . . Setting dimension state . . . . . . . . . Using paged dimensions . . . . . . . .

. . 22-12 . . 22-12 . . . . . . . . . . . . . . 22-12 22-12 22-13 22-13 22-14 22-15 22-16

Obtaining metadata. . . . . . . . . . . . Listing available tables . . . . . . . . Listing the fields in a table . . . . . . Listing available stored procedures . Listing available indexes . . . . . . . Listing stored procedure parameters

. . . . . .

. . . . . .

. . . . . .

23-13 23-14 23-14 23-14 23-14 23-15

Chapter 24

Understanding datasetsUsing TDataSet descendants . . . . . . Determining dataset states. . . . . . . . Opening and closing datasets . . . . . . Navigating datasets. . . . . . . . . . . . Using the First and Last methods . . Using the Next and Prior methods . Using the MoveBy method . . . . . . Using the Eof and Bof properties . . Eof . . . . . . . . . . . . . . . . . Bof . . . . . . . . . . . . . . . . . Marking and returning to records . . The Bookmark property . . . . . The GetBookmark method . . . The GotoBookmark and BookmarkValid methods . . . . The CompareBookmarks method The FreeBookmark method . . . A bookmarking example . . . . Searching datasets . . . . . . . . . . . . Using Locate . . . . . . . . . . . . . . Using Lookup . . . . . . . . . . . . . Displaying and editing a subset of data using filters . . . . . . . . . . . . . . . Enabling and disabling filtering . . . Creating filters . . . . . . . . . . . . . Setting the Filter property . . . . Writing an OnFilterRecord event handler . . . . . . . . . . Switching filter event handlers at runtime . . . . . . . . . . . . Setting filter options. . . . . . . . . . Navigating records in a filtered dataset . . . . . . . . . . . . . . . . Modifying data . . . . . . . . . . . . . . Editing records. . . . . . . . . . . . . Adding new records . . . . . . . . . Inserting records . . . . . . . . . Appending records . . . . . . . . Deleting records . . . . . . . . . . . . Posting data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

24-1. 24-2 . 24-3 . 24-4 . 24-5 . 24-6 . 24-7 . 24-7 . 24-8 . 24-8 . 24-9 . 24-9 . 24-9 24-10 24-10 24-10 24-10 24-10 24-11 24-11 24-12 24-13 24-13 24-13 24-14

. . 22-17 . . 22-18 . . . . . . . . 22-19 22-19 22-19 22-20

. . 22-20 . . 22-20 . . 22-21 . . 22-21

Chapter 23

Connecting to databasesUsing implicit connections . . . . . . . . Controlling connections . . . . . . . . . . Connecting to a database server . . . Disconnecting from a database server Controlling server login . . . . . . . . . . Managing transactions . . . . . . . . . . Starting a transaction . . . . . . . . . Ending a transaction . . . . . . . . . . Ending a successful transaction . Ending an unsuccessful transaction . . . . . . . . . . . . Specifying the transaction isolation level . . . . . . . . . . . . . Sending commands to the server . . . . Working with associated datasets . . . . Closing all datasets without disconnecting from the server. . . . Iterating through the associated datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

23-123-2 23-3 23-3 23-4 23-4 23-6 23-7 23-8 23-8

. . . . . . . . . . . . . . . . . . . . .

. . . 24-15 . . . 24-16 . . . 24-16 . . . . . . . . . . . . . . . . . . . . . . . . 24-16 24-17 24-18 24-19 24-19 24-20 24-20 24-21

. . . 23-9 . . . 23-9 . . . 23-10 . . . 23-12 . . . 23-12 . . . 23-13

xiii

Canceling changes . . . . . . . . . . . Modifying entire records . . . . . . . Calculating fields . . . . . . . . . . . . . Types of datasets . . . . . . . . . . . . . . Using table type datasets . . . . . . . . . Advantages of using table type datasets . . . . . . . . . . . . . . . . Sorting records with indexes . . . . . Obtaining information about indexes . . . . . . . . . . . . . . Specifying an index with IndexName . . . . . . . . . . . . Creating an index with IndexFieldNames . . . . . . . . Using Indexes to search for records . Executing a search with Goto methods . . . . . . . . . . . . . . Executing a search with Find methods . . . . . . . . . . . . . . Specifying the current record after a successful search . . . . . . . . Searching on partial keys . . . . . Repeating or extending a search . Limiting records with ranges . . . . . Understanding the differences between ranges and filters . . . Specifying ranges . . . . . . . . . Modifying a range . . . . . . . . . Applying or canceling a range . . Creating master/detail relationships. Making the table a detail of another dataset . . . . . . . . . . Using nested detail tables . . . . Controlling Read/write access to tables . . . . . . . . . . . . . . . . Creating and deleting tables . . . . . Creating tables . . . . . . . . . . . Deleting tables . . . . . . . . . . . Emptying tables . . . . . . . . . . . . Synchronizing tables . . . . . . . . . . Using query-type datasets . . . . . . . . Specifying the query . . . . . . . . . . Specifying a query using the SQL property . . . . . . . . . . . Specifying a query using the CommandText property . . . .

. . . . .

. . . . .

. . . . .

24-21 24-22 24-23 24-24 24-25

. . . 24-26 . . . 24-26 . . . 24-27 . . . 24-27 . . . 24-28 . . . 24-28 . . . 24-29 . . . 24-30 . . . . . . . . . . . . . . . . . . . . . . . . . . . 24-30 24-30 24-30 24-31 24-31 24-31 24-34 24-34 24-35

Using parameters in queries . . . . . . . . Supplying parameters at design time . . . . . . . . . . . . . . . . . . . Supplying parameters at runtime . . Establishing master/detail relationships using parameters . . . . . . . . . . . . . Preparing queries . . . . . . . . . . . . . . Executing queries that dont return a result set . . . . . . . . . . . . . . . . . Using unidirectional result sets . . . . . . Using stored procedure-type datasets . . . . Working with stored procedure parameters . . . . . . . . . . . . . . . . . Setting up parameters at design time . . . . . . . . . . . . . . Using parameters at runtime . . . . . Preparing stored procedures . . . . . . . . Executing stored procedures that dont return a result set . . . . . . . . . . . . . Fetching multiple result sets . . . . . . . .

24-45 24-45 24-47 24-47 24-48 24-49 24-49 24-50 24-51 24-52 24-54 24-55 24-55 24-56

Chapter 25

Working with field componentsDynamic field components . . . . . . . . . Persistent field components . . . . . . . . . Creating persistent fields . . . . . . . . . Arranging persistent fields . . . . . . . . Defining new persistent fields . . . . . . Defining a data field . . . . . . . . . Defining a calculated field . . . . . . Programming a calculated field . . . Defining a lookup field . . . . . . . Defining an aggregate field . . . . . Deleting persistent field components . . Setting persistent field properties and events . . . . . . . . . . . . . . . . Setting display and edit properties at design time . . . . . . . . . . . . Setting field component properties at runtime . . . . . . . . . . . . . . Creating attribute sets for field components . . . . . . . . . . . . . Associating attribute sets with field components . . . . . . . . . . . . . Removing attribute associations . . Controlling and masking user input . . . . . . . . . . . . . . . . . . . . . . . . .

25-1. 25-2 . 25-3 . 25-4 . 25-5 . 25-5 . 25-6 . 25-7 . 25-8 . 25-9 25-10 25-11

. . . 24-35 . . . 24-37 . . . . . . . . . . . . . . . . . . . . . . . . 24-38 24-38 24-38 24-41 24-41 24-42 24-42 24-43

. 25-11 . 25-11 . 25-13 . 25-13 . 25-14 . 25-14 . 25-15

. . . 24-44 . . . 24-44

xiv

Using default formatting for numeric, date, and time fields . . . . . . . . . Handling events . . . . . . . . . . . . Working with field component methods at runtime . . . . . . . . . . . . . . . . . . . Displaying, converting, and accessing field values . . . . . . . . . . . . . . . . . . Displaying field component values in standard controls . . . . . . . . . . . . . Converting field values . . . . . . . . . . Accessing field values with the default dataset property . . . . . . . . . . . . . Accessing field values with a datasets Fields property . . . . . . . . . . . . . . Accessing field values with a datasets FieldByName method . . . . . . . . . . Setting a default value for a field. . . . . . . Working with constraints . . . . . . . . . . . Creating a custom constraint . . . . . . . Using server constraints . . . . . . . . . . Using object fields . . . . . . . . . . . . . . . Displaying ADT and array fields . . . . . Working with ADT fields . . . . . . . . . Using persistent field components . . . . . . . . . . . . . Using the datasets FieldByName method . . . . . . . . . . . . . . . . Using the datesets FieldValues property . . . . . . . . . . . . . . . . Using the ADT fields FieldValues property . . . . . . . . . . . . . . . . Using the ADT fields Fields property . . . . . . . . . . . . . . . . Working with array fields . . . . . . . . . Using persistent fields . . . . . . . . Using the array fields FieldValues property . . . . . . . . . . . . . . . . Using the array fields Fields property . . . . . . . . . . . . . . . . Working with dataset fields . . . . . . . . Displaying dataset fields . . . . . . . Accessing data in a nested dataset . . Working with reference fields. . . . . . . Displaying reference fields . . . . . . Accessing data in a reference field . .

. 25-15 . 25-16 . 25-17 . 25-18 . 25-18 . 25-19 . 25-20 . 25-21 . . . . . . . . 25-21 25-22 25-22 25-22 25-23 25-23 25-24 25-25

Chapter 26

Using the Borland Database Engine 26-1BDE-based architecture. . . . . . . . . . . . Using BDE-enabled datasets . . . . . . . Associating a dataset with database and session connections . . . . . . Caching BLOBs . . . . . . . . . . . . Obtaining a BDE handle . . . . . . . Using TTable . . . . . . . . . . . . . . . . Specifying the table type for local tables . . . . . . . . . . . . . . . . . Controlling read/write access to local tables . . . . . . . . . . . . . . Specifying a dBASE index file . . . . Renaming local tables . . . . . . . . Importing data from another table . Using TQuery . . . . . . . . . . . . . . . Creating heterogeneous queries . . Obtaining an editable result set . . . Updating read-only result sets . . . Using TStoredProc . . . . . . . . . . . . Binding parameters . . . . . . . . . Working with Oracle overloaded stored procedures . . . . . . . . . . Connecting to databases with TDatabase . . . . . . . . . . . . . . . . Associating a database component with a session . . . . . . . . . . . . Understanding database and session component interactions . . . . . . Identifying the database . . . . . . . Opening a connection using TDatabase . . . . . . . . . . . . . . Using database components in data modules . . . . . . . . . . . . . . . Managing database sessions . . . . . . . Activating a session . . . . . . . . . Specifying default database connection behavior . . . . . . . . Managing database connections . . Working with password-protected Paradox and dBASE tables . . . . Specifying Paradox directory locations . . . . . . . . . . . . . . . Working with BDE aliases . . . . . . Retrieving information about a session . . . . . . . . . . . . . . . . . 26-1 . . 26-2 . . . . . . . . 26-3 26-4 26-4 26-5

. . 26-5 . . . . . . . . . . . 26-6 . 26-6 . 26-8 . 26-8 . 26-9 . 26-9 26-10 26-11 26-11 26-12

. 25-25 . 25-25 . 25-25 . 25-26 . 25-26 . 25-26 . 25-26 . 25-27 . . . . . . . 25-27 25-27 25-27 25-28 25-28 25-28 25-29

. 26-12 . 26-12 . 26-13 . 26-13 . 26-14 . 26-15 . 26-16 . 26-16 . 26-18 . 26-18 . 26-19 . 26-21 . 26-24 . 26-25 . 26-27

xv

Creating additional sessions . . . . . . Naming a session . . . . . . . . . . . . Managing multiple sessions . . . . . . Using transactions with the BDE . . . . . . . . Using passthrough SQL . . . . . . . . . . . Using local transactions . . . . . . . . . . . Using the BDE to cache updates . . . . . . . . Enabling BDE-based cached updates . . . Applying BDE-based cached updates . . . Applying cached updates using a database . . . . . . . . . . . . . . . . Applying cached updates with dataset component methods . . . . . . . . . . Creating an OnUpdateRecord event handler . . . . . . . . . . . . . . Handling cached update errors . . . . Using update objects to update a dataset . . . . . . . . . . . . . . . . . . . Creating SQL statements for update components . . . . . . . . . . . . . . Using multiple update objects . . . . . Executing the SQL statements . . . . . Using TBatchMove. . . . . . . . . . . . . . . . Creating a batch move component . . . . . Specifying a batch move mode . . . . . . . Appending records . . . . . . . . . . . Updating records . . . . . . . . . . . . Appending and updating records . . . . . . . . . . . . . . . . . Copying datasets . . . . . . . . . . . . Deleting records . . . . . . . . . . . . . Mapping data types . . . . . . . . . . . . . Executing a batch move . . . . . . . . . . . Handling batch move errors . . . . . . . . The Data Dictionary . . . . . . . . . . . . . . . Tools for working with the BDE . . . . . . . .

26-28 26-29 26-29 26-31 26-32 26-32 26-33 26-34 26-35 26-36 26-36 26-37 26-38 26-40 26-41 26-45 26-46 26-49 26-49 26-50 26-50 26-50 26-51 26-51 26-51 26-51 26-52 26-52 26-53 26-55

Indicating the types of operations the connection supports . . . . . Specifying whether the connection automatically initiates transactions . . . . . . . . . . . . Accessing the connections commands . . . . . . . . . . . . . . . ADO connection events. . . . . . . . . Events when establishing a connection . . . . . . . . . . . . . Events when disconnecting . . . . Events when managing transactions . . . . . . . . . . . . Other events . . . . . . . . . . . . . Using ADO datasets . . . . . . . . . . . . Connecting an ADO dataset to a data store . . . . . . . . . . . . Working with record sets . . . . . Filtering records based on bookmarks . . . . . . . . . . . . . Fetching records asynchronously . Using batch updates . . . . . . . . Loading data from and saving data to files . . . . . . . . . . . . Using TADODataSet . . . . . . . . . . Using Command objects . . . . . . . . . . Specifying the command . . . . . . . . Using the Execute method . . . . . . . Canceling commands . . . . . . . . . . Retrieving result sets with commands Handling command parameters . . . .

. . . 27-6

. . . 27-7 . . . 27-7 . . . 27-8 . . . 27-8 . . . 27-8 . . . 27-9 . . . 27-9 . . . 27-9 . . 27-10 . . 27-11 . . 27-11 . . 27-12 . . 27-13 . . . . . . . . . . . . . . . . 27-15 27-16 27-18 27-18 27-19 27-19 27-20 27-20

Chapter 28

Using unidirectional datasetsTypes of unidirectional datasets . . . . . . Connecting to the database server . . . . Setting up TSQLConnection . . . . . . Identifying the driver . . . . . . . Specifying connection parameters Naming a connection description . Using the Connection Editor . . . Specifying what data to display . . . . . . Representing the results of a query . . Representing the records in a table . . Representing a table using TSQLDataSet . . . . . . . . . . . Representing a table using TSQLTable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

28-1. . . . . . . . . . 28-2 28-2 28-3 28-3 28-4 28-4 28-5 28-6 28-6 28-7

Chapter 27

Working with ADO componentsOverview of ADO components . . . . Connecting to ADO data stores . . . . Connecting to a data store using TADOConnection. . . . . . . . . . Accessing the connection object Fine-tuning a connection . . . . . . Forcing asynchronous connections . . . . . . . . . . . Controlling time-outs . . . . . .

27-1. . . . 27-2 . . . . 27-3

. . . . 27-3 . . . . 27-5 . . . . 27-5 . . . . 27-5 . . . . 27-6

. . . 28-7 . . . 28-7

xvi

Representing the results of a stored procedure . . . . . . . . . . . . . Fetching the data. . . . . . . . . . . . . . . . Preparing the dataset . . . . . . . . . . . Fetching multiple datasets . . . . . . . . Executing commands that do not return records. . . . . . . . . . . . . . . . . Specifying the command to execute . . . Executing the command . . . . . . . . . . Creating and modifying server metadata . . . . . . . . . . . . . . . . . . Setting up master/detail linked cursors. . . Accessing schema information . . . . . . . . Fetching metadata into a unidirectional dataset . . . . . . . . . . . . . . . . . . . Fetching data after using the dataset for metadata . . . . . . . . . . . . . The structure of metadata datasets . . . . . . . . . . . . . . . . Debugging dbExpress applications . . . . . Using TSQLMonitor to monitor SQL commands . . . . . . . . . . . . . . Using a callback to monitor SQL commands . . . . . . . . . . . . . .

. . . .

28-8 28-8 28-9 28-9

. 28-10 . 28-10 . 28-11 . 28-11 . 28-12 . 28-13 . 28-13 . 28-14 . 28-14 . 28-19 . 28-19 . 28-20

Chapter 29

Using client datasetsWorking with data using a client dataset Navigating data in client datasets . . Limiting what records appear. . . . . Editing data . . . . . . . . . . . . . . . Undoing changes . . . . . . . . . Saving changes . . . . . . . . . . Constraining data values . . . . . . . Specifying custom constraints . . Sorting and indexing. . . . . . . . . . Adding a new index . . . . . . . . Deleting and switching indexes . Using indexes to group data . . . Representing calculated values . . . . Using internally calculated fields in client datasets . . . . . . . . . Using maintained aggregates . . . . . Specifying aggregates . . . . . . Aggregating over groups of records . . . . . . . . . . . . . . Obtaining aggregate values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

29-129-2 29-2 29-2 29-5 29-5 29-6 29-7 29-7 29-8 29-8 29-9 29-9 29-10

. . . 29-11 . . . 29-11 . . . 29-12 . . . 29-13 . . . 29-14

Copying data from another dataset . . . . Assigning data directly . . . . . . . . Cloning a client dataset cursor . . . . Adding application-specific information to the data . . . . . . . . . . . . . . . . . Using a client dataset to cache updates. . . . Overview of using cached updates . . . . Choosing the type of dataset for caching updates . . . . . . . . . . . . . . . . . . . Indicating what records are modified . . . Updating records . . . . . . . . . . . . . . Applying updates . . . . . . . . . . . Intervening as updates are applied . . . . . . . . . . . . . . . . . Reconciling update errors . . . . . . . Using a client dataset with a provider . . . . Specifying a provider . . . . . . . . . . . . Requesting data from the source dataset or document . . . . . . . . . . . . . . . . Incremental fetching . . . . . . . . . . Fetch-on-demand . . . . . . . . . . . . Getting parameters from the source dataset . . . . . . . . . . . . . . . . . . . Passing parameters to the source dataset . . . . . . . . . . . . . . . . . . . Sending query or stored procedure parameters . . . . . . . . . . . . . . . Limiting records with parameters . . Handling constraints from the server . . . Refreshing records. . . . . . . . . . . . . . Communicating with providers using custom events . . . . . . . . . . . . . . . Overriding the source dataset . . . . . . . Using a client dataset with file-based data . . . . . . . . . . . . . . . . . . . . . . . Creating a new dataset . . . . . . . . . . . Loading data from a file or stream . . . . Merging changes into data . . . . . . . . . Saving data to a file or stream . . . . . . . Using a simple dataset . . . . . . . . . . . . . When to use TSimpleDataSet . . . . . . . Setting up a simple dataset . . . . . . . . .

29-14 29-14 29-15 29-15 29-16 29-17 29-18 29-19 29-20 29-20 29-21 29-23 29-24 29-25 29-26 29-26 29-27 29-27 29-28 29-29 29-29 29-30 29-31 29-31 29-32 29-33 29-33 29-34 29-34 29-35 29-35 29-36 29-36

xvii

Chapter 30

Using provider componentsDetermining the source of data. . . . . . . Using a dataset as the source of the data . . . . . . . . . . . . . . . . Using an XML document as the source of the data . . . . . . . . . . . . . . . . Communicating with the client dataset . . Choosing how to apply updates using a dataset provider . . . . . . . . . . . . . Controlling what information is included in data packets . . . . . . . . . . . . . . . Specifying what fields appear in data packets . . . . . . . . . . . . . . . Setting options that influence the data packets . . . . . . . . . . . . . . . Adding custom information to data packets . . . . . . . . . . . . . . . Responding to client data requests. . . . . Responding to client update requests . . . Editing delta packets before updating the database . . . . . . . . . . . . . . . Influencing how updates are applied . Screening individual updates . . . . . . Resolving update errors on the provider . . . . . . . . . . . . . . . Applying updates to datasets that do not represent a single table . . . . . . Responding to client-generated events . . Handling server constraints . . . . . . . .

30-1. . 30-2 . . 30-2 . . 30-2 . . 30-3 . . 30-4 . . 30-4 . . 30-4 . . 30-5 . . 30-6 . . 30-7 . . 30-8 . . 30-9 . . 30-10 . . 30-11 . . 30-11 . . 30-12 . . 30-12 . . 30-13

Chapter 31

Creating multi-tiered applicationsAdvantages of the multi-tiered database model . . . . . . . . . . . . . . . Understanding multi-tiered database applications . . . . . . . . . . . . . . . . . Overview of a three-tiered application. The structure of the client application . The structure of the application server. The contents of the remote data module . . . . . . . . . . . . Using transactional data modules . Pooling remote data modules . . . Choosing a connection protocol . . . . Using DCOM connections . . . . . Using Socket connections . . . . . . Using Web connections . . . . . . . Using SOAP connections . . . . . .

31-1. . 31-2 . . . . . . . . . . . . . . . . . . . . . . . . 31-2 31-3 31-4 31-5 31-6 31-7 31-8 31-9 31-9 31-9 31-10 31-11

Building a multi-tiered application . . . . . . Creating the application server . . . . . . . . Setting up the remote data module . . . . Configuring TRemoteDataModule . . . . . . . . Configuring TMTSDataModule . . . Configuring TSoapDataModule . . . Extending the application servers interface. . . . . . . . . . . . . . . . . . . Adding callbacks to the application servers interface . . . . . . . . . . . Extending a transactional application servers interface . . . . . . . . . . . Managing transactions in multi-tiered applications . . . . . . . . . . . . . . . . Supporting master/detail relationships . . . . . . . . . . . . . . . . Supporting state information in remote data modules. . . . . . . . . . . . . . . . Using multiple remote data modules . . . Registering the application server . . . . . . Creating the client application. . . . . . . . . Connecting to the application server . . . Specifying a connection using DCOM . . . . . . . . . . . . . Specifying a connection using sockets . . . . . . . . . . . . . Specifying a connection using HTTP . . . . . . . . . . . . . . Specifying a connection using SOAP . . . . . . . . . . . . . . Brokering connections . . . . . . . . . Managing server connections . . . . . . . Connecting to the server . . . . . . . . Dropping or changing a server connection . . . . . . . . . . . . . . . Calling server interfaces . . . . . . . . . . Using early binding with DCOM . . . Using dispatch interfaces with TCP/IP or HTTP . . . . . . . . . . . Calling the interface of a SOAP-based server . . . . . . . . . . . . . . . . . . Connecting to an application server that uses multiple data modules . . . . . . . Writing Web-based client applications . . . . Distributing a client application as an ActiveX control . . . . . . . . . . . . . . Creating an Active Form for the client application . . . . . . . . . . . . . . .

31-11 31-12 31-13 31-13 31-15 31-16 31-16 31-17 31-17 31-17 31-18 31-19 31-21 31-22 31-22 31-23 31-24 31-24 31-25 31-26 31-27 31-27 31-27 31-28 31-28 31-29 31-29 31-30 31-30 31-31 31-32 31-33

xviii

Building Web applications using InternetExpress . . . . . . . . . . . . Building an InternetExpress application. . . . . . . . . . . . . . . Using the javascript libraries . . . Granting permission to access and launch the application server . . Using an XML broker . . . . . . . . . Fetching XML data packets . . . . Applying updates from XML delta packets . . . . . . . . . . . Creating Web pages with an InternetExpress page producer . . . Using the Web page editor . . . . Setting Web item properties . . . Customizing the InternetExpress page producer template . . . . .

. . . 31-33 . . . 31-34 . . . 31-35 . . . 31-36 . . . 31-36 . . . 31-36 . . . 31-37 . . . 31-39 . . . 31-39 . . . 31-40 . . . 31-41

Part III

Writing Internet applicationsChapter 33

Creating Internet server applicationsAbout Web Broker and WebSnap . . . . . Terminology and standards . . . . . . . . Parts of a Uniform Resource Locator . URI vs. URL . . . . . . . . . . . . . HTTP request header information. . . HTTP server activity . . . . . . . . . . . . Composing client requests . . . . . . . Serving client requests . . . . . . . . . Responding to client requests . . . . . Types of Web server applications . . . . . ISAPI and NSAPI . . . . . . . . . . CGI stand-alone . . . . . . . . . . Apache . . . . . . . . . . . . . . . . Web App Debugger . . . . . . . . Converting Web server application target types . . . . . . . . . . . . . . . Debugging server applications . . . . . . Using the Web Application Debugger Launching your application with the Web Application Debugger . Converting your application to another type of Web server application . . . . . . . . . . . . . Debugging Web applications that are DLLs. . . . . . . . . . . . . . User rights necessary for DLL debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

33-1. . . . . . . . . . . . . . 33-1 33-3 33-3 33-4 33-4 33-5 33-5 33-5 33-6 33-6 33-6 33-6 33-7 33-7

Chapter 32

Using XML in database applicationsDefining transformations . . . . . . . . . . Mapping between XML nodes and data packet fields . . . . . . . . . . . . Using XMLMapper. . . . . . . . . . . . Loading an XML schema or data packet . . . . . . . . . . . . . Defining mappings . . . . . . . . . Generating transformation files . . Converting XML documents into data packets. . . . . . . . . . . . . . . . . Specifying the source XML document . Specifying the transformation . . . . . Obtaining the resulting data packet . . Converting user-defined nodes . . . . . Using an XML document as the source for a provider . . . . . . . . . . . . . . . . Using an XML document as the client of a provider . . . . . . . . . . . . . . . . Fetching an XML document from a provider . . . . . . . . . . . . . . . . Applying updates from an XML document to a provider . . . . . . . .

32-1. . 32-1 . . 32-2 . . 32-4 . . 32-4 . . 32-5 . . 32-6 . . . . . . . . . . 32-6 32-6 32-7 32-7 32-7

. . . 33-8 . . . 33-9 . . . 33-9 . . . 33-9

. . 33-10 . . 33-10 . . 33-10

Chapter 34

. . 32-8 . . 32-9 . . 32-9 . . 32-11

Using Web BrokerCreating Web server applications with Web Broker. . . . . . . . . . . . . . . . The Web module. . . . . . . . . . . . The Web Application object . . . . . The structure of a Web Broker application . . . . . . . . . . . . . . . . The Web dispatcher. . . . . . . . . . . . Adding actions to the dispatcher . . Dispatching request messages . . . .

34-1. . . . 34-1 . . . . 34-2 . . . . 34-3 . . . . . . . . . . . . . . . . 34-3 34-5 34-5 34-5

xix

Action items . . . . . . . . . . . . . . . . . . Determining when action items fire . . . The target URL . . . . . . . . . . . . . The request method type . . . . . . . Enabling and disabling action items . . . . . . . . . . . . . . . . . . Choosing a default action item . . . . Responding to request messages with action items . . . . . . . . . . . . . . . . Sending the response . . . . . . . . . Using multiple action items . . . . . Accessing client request information . . . . Properties that contain request header information . . . . . . . . . . . . . . . . Properties that identify the target . . Properties that describe the Web client . . . . . . . . . . . . . . . Properties that identify the purpose of the request . . . . . . . . . . . . . Properties that describe the expected response . . . . . . . . . . . . . . . Properties that describe the content . . . . . . . . . . . . . . . . The content of HTTP request messages. . . . . . . . . . . . . . . . . . Creating HTTP response messages . . . . . Filling in the response header. . . . . . . Indicating the response status . . . . Indicating the need for client action . . . . . . . . . . . . . . . . . Describing the server application . . Describing the content . . . . . . . . Setting the response content . . . . . . . Sending the response . . . . . . . . . . . Generating the content of response messages . . . . . . . . . . . . . . . . . . . Using page producer components . . . . HTML templates . . . . . . . . . . . . Specifying the HTML template . . . Converting HTML-transparent tags . . . . . . . . . . . . . . . . . . Using page producers from an action item . . . . . . . . . . . . . . Chaining page producers together . . . . . . . . . . . . . . . . Using database information in responses . . . . . . . . . . . . . . . . . . . Adding a session to the Web module . .

. . . .

34-6 34-6 34-6 34-7

. 34-7 . 34-7 . . . . 34-8 34-8 34-9 34-9

Representing database information in HTML . . . . . . . . . . . . . . . Using dataset page producers . . Using table producers . . . . . . Specifying the table attributes . . Specifying the row attributes . . Specifying the columns . . . . . Embedding tables in HTML documents . . . . . . . . . . . . Setting up a dataset table producer . . . . . . . . . . . . . Setting up a query table producer . . . . . . . . . . . . .

. . . . . .

. . . . . .

. . . . . .

34-19 34-19 34-20 34-20 34-20 34-20

. . . 34-21 . . . 34-21 . . . 34-21

. 34-9 . 34-9 . 34-10 . 34-10 . 34-10 . 34-11 . . . . . . . . . . . . . 34-11 34-11 34-11 34-12 34-12 34-12 34-12 34-13 34-13 34-13 34-14 34-14 34-15

Chapter 35

Creating Web Server applications using WebSnapFundamental WebSnap components . . Web modules. . . . . . . . . . . . . . Web application module types . Web page modules . . . . . . . . Web data modules . . . . . . . . Adapters . . . . . . . . . . . . . . . . Fields . . . . . . . . . . . . . . . . Actions . . . . . . . . . . . . . . . Errors . . . . . . . . . . . . . . . Records . . . . . . . . . . . . . . Page producers . . . . . . . . . . . . Creating Web server applications with WebSnap . . . . . . . . . . . . . . Selecting a server type . . . . . . . . Specifying application module components . . . . . . . . . . . . . Selecting Web application module options . . . . . . . . . . . . . . . . Advanced HTML design. . . . . . . . . Manipulating server-side script in HTML files . . . . . . . . . . . . . . Login support . . . . . . . . . . . . . . . Adding login support. . . . . . . . . Using the sessions service . . . . . . Login pages . . . . . . . . . . . . . . Setting pages to require logins . . . . User access rights . . . . . . . . . . . Dynamically displaying fields as edit or text boxes . . . . . . . . Hiding fields and their contents Preventing page access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

35-1. . . . . . . . . . . 35-2 35-2 35-3 35-4 35-5 35-5 35-6 35-6 35-6 35-6 35-6

. . . . 35-7 . . . . 35-8 . . . . 35-9 . . . 35-10 . . . 35-11 . . . . . . . . . . . . . . . . . . . . . 35-12 35-13 35-13 35-14 35-15 35-17 35-17

. 34-16 . 34-16 . 34-17 . 34-18 . 34-18

. . . 35-18 . . . 35-18 . . . 35-19

xx

Server-side scripting in WebSnap . . . Active scripting . . . . . . . . . . . . Script engine . . . . . . . . . . . . . Script blocks. . . . . . . . . . . . . . Creating script . . . . . . . . . . . . Wizard templates . . . . . . . . TAdapterPageProducer . . . . . Editing and viewing script . . . . . Including script in a page . . . . . . Script objects . . . . . . . . . . . . . Dispatching requests and responses . . Dispatcher components . . . . . . . Adapter dispatcher operation. . . . Using adapter components to generate content . . . . . . . . Receiving adapter requests and generating responses . . . . . Image request . . . . . . . . . . Image response . . . . . . . . . Dispatching action items . . . . . . Page dispatcher operation . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

35-19 35-20 35-20 35-20 35-21 35-21 35-21 35-21 35-21 35-22 35-22 35-23 35-23

Abstracting XML documents with the Data Binding wizard . . . . . . . . . . . . . . 37-6 Using the XML Data Binding wizard . . . . 37-8 Using code that the XML Data Binding wizard generates. . . . . . . . . . 37-9

Chapter 38

Using Web ServicesUnderstanding invokable interfaces . . . . . Using nonscalar types in invokable interfaces . . . . . . . . . . . . . . . . . . Registering nonscalar types . . . . . . Using remotable objects . . . . . . . . Representing attachments . . . . . . . Managing the lifetime of remotable objects . . . . . . . . . . . . . . . . . Remotable object example . . . . . . . Writing servers that support Web Services. . Building a Web Service server . . . . . . . Using the SOAP application wizard . . . Adding new Web Services . . . . . . . . . Editing the generated code . . . . . . Using a different base class . . . . . . Using the WSDL importer . . . . . . . . . Browsing for Business services . . . . . . Understanding UDDI . . . . . . . . . Using the UDDI browser . . . . . . . Defining and using SOAP headers . . . . Defining header classes . . . . . . . . Sending and receiving headers . . . . Handling scalar-type headers . . . . . Communicating the structure of your headers to other applications . . . . Creating custom exception classes for Web Services . . . . . . . . . . . . . . . . Generating WSDL documents for a Web Service application. . . . . . . . . Writing clients for Web Services. . . . . . . . Importing WSDL documents . . . . . . . Calling invokable interfaces . . . . . . . . Obtaining an invokable interface from the generated function . . . . . Using a remote interfaced object . . . Processing headers in client applications . . . . . . . . . . . . . . . .

38-1. 38-2 . . . . 38-4 38-5 38-6 38-7

. . . . 35-23 . . . . . . . . . . . . . . . . . . . . 35-25 35-26 35-27 35-27 35-28

Chapter 36

Creating Web server applications using IntraWebUsing IntraWeb components . . . . . . . Getting started with IntraWeb . . . . . . Creating a new IntraWeb application Editing the main form . . . . . . . . . Writing an event handler for the button . . . . . . . . . . . . . . . Running the completed application . Using IntraWeb with Web Broker and WebSnap . . . . . . . . . . . . . . . For more information . . . . . . . . . . . . . . . . . . . . . . .

36-136-2 36-3 36-4 36-4

. . . 36-5 . . . 36-6 . . . 36-7 . . . 36-8

. 38-7 . 38-7 . 38-9 . 38-9 38-10 38-11 38-12 38-12 38-13 38-14 38-15 38-15 38-16 38-16 38-16 38-17 38-18 38-18 38-19 38-20 38-20 38-20 38-21 38-21 38-23

Chapter 37

Working with XML documentsUsing the Document Object Model . . . Working with XML components . . . . . Using TXMLDocument . . . . . . . . Working with XML nodes . . . . . . . Working with a nodes value . . . Working with a nodes attributes Adding and deleting child nodes . . . . . . . . . . . . . . . . . . . . .

37-137-2 37-4 37-4 37-4 37-5 37-5 37-6

xxi

Chapter 39

Part IV

Working with socketsImplementing services . . . . . . . . . Understanding service protocols . . Communicating with applications . . . . . . . . . . . Services and ports . . . . . . . . . . Types of socket connections. . . . . . . Client connections . . . . . . . . . . Listening connections . . . . . . . . Server connections . . . . . . . . . . Describing sockets . . . . . . . . . . . . Describing the host . . . . . . . . . . Choosing between a host name and an IP address . . . . . . . Using ports . . . . . . . . . . . . . . Using socket components . . . . . . . . Getting information about the connection . . . . . . . . . . . . . . Using client sockets . . . . . . . . . Specifying the desired server . . Forming the connection . . . . . Getting information about the connection . . . . . . . . . . . Closing the connection . . . . . Using server sockets . . . . . . . . . Specifying the port . . . . . . . Listening for client requests . . Connecting to clients . . . . . . Closing server connections . . . Responding to socket events . . . . . . Error events . . . . . . . . . . . . . . Client events . . . . . . . . . . . . . Server events . . . . . . . . . . . . . Events when listening . . . . . . Events with client connections . Reading and writing over socket connections . . . . . . . . . . . . . . . Non-blocking connections. . . . . . Reading and writing events . . Blocking connections. . . . . . . . .

39-1. . . . 39-1 . . . . 39-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39-2 39-2 39-3 39-3 39-3 39-3 39-4 39-4

Developing COM-based applicationsChapter 40

Overview of COM technologiesCOM as a specification and implementation . . . . . . . . . COM extensions . . . . . . . . . Parts of a COM application . . . . . . . COM interfaces . . . . . . . . . . . . The fundamental COM interface, IUnknown . . . . . . . . . . . . COM interface pointers . . . . . COM servers . . . . . . . . . . . . . . CoClasses and class factories . . In-process, out-of-process, and remote servers . . . . . . . . . . The marshaling mechanism . . . Aggregation . . . . . . . . . . . . COM clients . . . . . . . . . . . . . . COM extensions. . . . . . . . . . . . . . Automation servers . . . . . . . . . . Active Server Pages . . . . . . . . . . ActiveX controls . . . . . . . . . . . . Active Documents. . . . . . . . . . . Transactional objects . . . . . . . . . Type libraries. . . . . . . . . . . . . . The content of type libraries . . . Creating type libraries . . . . . . When to use type libraries . . . . Accessing type libraries . . . . . Benefits of using type libraries . Using type library tools . . . . . Implementing COM objects with wizards . . . . . . . . . . . . . . . Code generated by wizards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

40-1. . . . . . . . 40-2 40-2 40-3 40-3 40-4 40-5 40-5 40-6

. . . . 39-5 . . . . 39-5 . . . . 39-6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39-6 39-6 39-7 39-7 39-7 39-7 39-7 39-8 39-8 39-8 39-8 39-8 39-9 39-9 39-9 39-9 39-10 39-10 39-10 39-11 39-11

. 40-7 . 40-8 . 40-9 40-10 40-10 40-12 40-13 40-13 40-14 40-15 40-16 40-16 40-17 40-17 40-18 40-18 40-19

. . . 40-19 . . . 40-22

xxii

Chapter 41

Chapter 42

Working with type librariesType Library editor . . . . . . . . . . . . . Parts of the Type Library editor. . . . . Toolbar . . . . . . . . . . . . . . . . Object list pane . . . . . . . . . . . . Status bar . . . . . . . . . . . . . . . Pages of type information . . . . . Type library elements . . . . . . . . . . Interfaces . . . . . . . . . . . . . . . Dispinterfaces . . . . . . . . . . . . CoClasses . . . . . . . . . . . . . . . Type definitions . . . . . . . . . . . Modules . . . . . . . . . . . . . . . Using the Type Library editor. . . . . . Valid types . . . . . . . . . . . . . . Using Delphi or IDL syntax . . . . Creating a new type library . . . . Opening an existing type library . Adding an interface to the type library . . . . . . . . . . . . . . . . Modifying an interface using the type library . . . . . . . . . . . . . Adding properties and methods to an interface or dispinterface . . . Adding a CoClass to the type library . . . . . . . . . . . . . . . . Adding an interface to a CoClass . Adding an enumeration to the type library . . . . . . . . . . . . . Adding an alias to the type library . . . . . . . . . . . . . . . . Adding a record or union to the type library . . . . . . . . . . . . . Adding a module to the type library . . . . . . . . . . . . . . . . Saving and registering type library information . . . . . . . . . . . . . Apply Updates dialog . . . . . . . Saving a type library . . . . . . . . Refreshing the type library . . . . . Registering the type library . . . . Exporting an IDL file . . . . . . . . Deploying type libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

41-141-2 41-3 41-3 41-5 41-5 41-6 41-8 41-9 41-9 41-10 41-10 41-11 41-11 41-12 41-13 41-19 41-20

Creating COM clientsImporting type library information . . . . Using the Import Type Library dialog Using the Import ActiveX dialog . . . Code generated when you import type library information . . . . . . . Controlling an imported object . . . . . . Using component wrappers . . . . . . ActiveX wrappers . . . . . . . . . Automation object wrappers . . . Using data-aware ActiveX controls . . Example: Printing a document with Microsoft Word . . . . . . . . . . . . Preparing Delphi for this example Importing the Word type library . Using a VTable or dispatch interface object to control Microsoft Word . . . . . . . . . . Cleaning up the example . . . . . Writing client code based on type library definitions . . . . . . . . . . . Connecting to a server . . . . . . . Controlling an Automation server using a dual interface . . . . . . Controlling an Automation server using a dispatch interface . . . . Handling events in an automation controller . . . . . . . . . . . . . . Creating clients for servers that do not have a type library . . . . . . . . . . . . Using .NET assemblies with Delphi . . . Requirements for COM interoperability . . . . . . . . . . . . .NET components and type libraries . Accessing user-defined .NET components . . . . . . . . . . . . . .

42-1. . . 42-2 . . . 42-3 . . . 42-4 . . . . . . . . . . . . . . . . . . 42-5 42-6 42-6 42-6 42-7 42-8

. . . 42-9 . . 42-10 . . 42-10

. . 42-11 . . 42-12 . . 42-13 . . 42-13 . . 42-13 . . 42-14 . . 42-14 . . 42-16 . . 42-17 . . 42-17 . . 42-18 . . 42-20

. . 41-21 . . 41-21 . . 41-22 . . 41-23 . . 41-23 . . 41-24 . . 41-24 . . 41-24 . . 41-25 . . . . . . . . . . . . . . 41-25 41-26 41-26 41-26 41-27 41-27 41-27

xxiii

Chapter 43

Creating simple COM serversOverview of creating a COM object . . . . Designing a COM object . . . . . . . . . . Using the COM object wizard . . . . . . . Using the Automation object wizard . . . COM object instancing types . . . . . . Choosing a threading model . . . . . . Writing an object that supports the free threading model . . . . . . . Writing an object that supports the apartment threading model . . . Writing an object that supports the neutral threading model . . . . . Defining a COM objects interface . . . . . Adding a property to the objects interface . . . . . . . . . . . . . . . . . Adding a method to the objects interface . . . . . . . . . . . . . . . . . Exposing events to clients . . . . . . . . Managing events in your Automation object . . . . . . . . . Automation interfaces . . . . . . . . . . . . Dual interfaces . . . . . . . . . . . . . . Dispatch interfaces . . . . . . . . . . . . Custom interfaces . . . . . . . . . . . . Marshaling data . . . . . . . . . . . . . . . Automation compatible types . . . . . Type restrictions for automatic marshaling . . . . . . . . . . . . . . . Custom marshaling . . . . . . . . . . . Registering a COM object . . . . . . . . . . Registering an in-process server . . . . Registering an out-of-process server . . Testing and debugging the application . . . . . . . . . . . . . .

43-143-2 43-2 43-3 43-5 43-6 43-6

Registering an Active Server Object . . . Registering an in-process server . . . . Registering an out-of-process server . Testing and debugging the Active Server Page application. . . . . . . . . . . . . .

. . . 44-8 . . . 44-8 . . . 44-8 . . . 44-8

Chapter 45

Creating an ActiveX controlOverview of ActiveX control creation . . Elements of an ActiveX control . . . . VCL control . . . . . . . . . . . . . ActiveX wrapper . . . . . . . . . . Type library . . . . . . . . . . . . . Property page . . . . . . . . . . . . Designing an ActiveX control . . . . . . . Generating an ActiveX control from a VCL control . . . . . . . . . . . . . . . . Generating an ActiveX control based on a VCL form. . . . . . . . . . . . . . . . . Licensing ActiveX controls. . . . . . . . . Customizing the ActiveX controls interface . . . . . . . . . . . . . . . . . . Adding additional properties, methods, and events . . . . . . . . . Adding properties and methods . Adding events . . . . . . . . . . . Enabling simple data binding with the type library. . . . . . . . . . . . . Creating a property page for an ActiveX control . . . . . . . . . . . . . . Creating a new property page . . . . . Adding controls to a property page . . Associating property page controls with ActiveX control properties . . . Updating the property page . . . . Updating the object . . . . . . . . Connecting a property page to an ActiveX control . . . . . . . . . . . . Registering an ActiveX control . . . . . . Testing an Acti