• Aucun résultat trouvé

Developer’s Guide

N/A
N/A
Protected

Academic year: 2022

Partager "Developer’s Guide"

Copied!
1140
0
0

Texte intégral

(1)

Developer’s Guide

Borland Software Corporation

Borland

®

Delphi

6

for Windows

(2)

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

(3)

Chapter 1

Introduction 1-1

What’s in this manual? . . . 1-1 Manual conventions . . . 1-3 Developer support services . . . 1-3 Ordering printed documentation . . . 1-3

Part I

Programming with Delphi

Chapter 2

Developing applications with Delphi 2-1

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

Chapter 3

Using the component libraries 3-1

Understanding the component libraries. . . 3-1 Properties, methods, and events . . . 3-2 Properties . . . 3-2 Methods . . . 3-3 Events . . . 3-3 User events . . . 3-3 System events . . . 3-4 Object Pascal and the class libraries . . . 3-4 Using the object model . . . 3-4 What is an object?. . . 3-5 Examining a Delphi object . . . 3-5 Changing the name of a component . . . 3-7 Inheriting data and code from an object . . . 3-8 Scope and qualifiers . . . 3-8

Private, protected, public, and published declarations . . . 3-9 Using object variables . . . . 3-10 Creating, instantiating, and destroying

objects . . . . 3-11 Components and ownership . . . . 3-11 Objects, components, and controls . . . . 3-12 TObject branch . . . . 3-14

TPersistent branch. . . 3-14 TComponent branch . . . 3-15 TControl branch . . . 3-16 TWinControl/TWidgetControl branch . . . 3-17 Properties common to TControl . . . 3-18 Action properties . . . 3-18 Position, size, and alignment

properties . . . 3-19 Display properties . . . 3-19 Parent properties. . . 3-19 A navigation property. . . 3-19 Drag-and-drop properties . . . 3-20 Drag-and-dock properties

(VCL only) . . . 3-20 Standard events common to TControl . . . 3-20 Properties common to TWinControl and

TWidgetControl . . . 3-21 General information properties . . . 3-21 Border style display properties. . . 3-22 Navigation properties . . . 3-22 Drag-and-dock properties

(VCL only) . . . 3-22 Events common to TWinControl and

TWidgetControl . . . 3-22 Creating the application user interface . . . 3-23 Using Delphi components . . . 3-23 Setting component properties . . . 3-24 Using the Object Inspector . . . 3-24 Using property editors . . . 3-25 Setting properties at runtime . . . 3-25 Calling methods . . . 3-25 Working with events and event

handlers. . . 3-25 Generating a new event handler . . . 3-26 Generating a handler for a component’s

default event . . . 3-26 Locating event handlers. . . 3-26 Associating an event with an existing

event handler . . . 3-27 Associating menu events with event

handlers . . . 3-28 Deleting event handlers . . . 3-28 VCL and CLX components . . . 3-28

Adding custom components to the

Component palette . . . 3-30 Text controls . . . 3-31 Text control properties. . . 3-31

Contents

(4)

Properties of memo and rich text

controls . . . . 3-31 Rich text controls (VCL only) . . . . 3-32 Specialized input controls . . . . 3-32 Scroll bars . . . . 3-32 Track bars . . . . 3-33 Up-down controls (VCL only). . . . 3-33 Spin edit controls (CLX only) . . . . 3-33 Hot key controls (VCL only). . . . 3-33 Splitter controls . . . . 3-34 Buttons and similar controls . . . . 3-34 Button controls . . . . 3-34 Bitmap buttons . . . . 3-35 Speed buttons . . . . 3-35 Check boxes . . . . 3-35 Radio buttons . . . . 3-35 Toolbars . . . . 3-36 Cool bars (VCL only) . . . . 3-36 Handling lists . . . . 3-36 List boxes and check-list boxes . . . . 3-37 Combo boxes . . . . 3-37 Tree views . . . . 3-38 List views . . . . 3-38 Date-time pickers and month

calendars (VCL only) . . . . 3-39 Grouping components . . . . 3-39 Group boxes and radio groups . . . . 3-39 Panels . . . . 3-39 Scroll boxes . . . . 3-40 Tab controls . . . . 3-40 Page controls . . . . 3-40 Header controls . . . . 3-41 Providing visual feedback . . . . 3-41 Labels and static text components . . . . 3-41 Status bars . . . . 3-42 Progress bars . . . . 3-42 Help and hint properties . . . . 3-42 Grids . . . . 3-43 Draw grids. . . . 3-43 String grids . . . . 3-43 Value list editors (VCL only) . . . . 3-43 Displaying graphics . . . . 3-44 Images . . . . 3-44 Shapes . . . . 3-44 Bevels . . . . 3-45 Paint boxes. . . . 3-45 Animation control (VCL only). . . . 3-45 Developing dialog boxes . . . . 3-45 Using open dialog boxes . . . . 3-46

Using helper objects . . . 3-46 Working with lists . . . 3-47 Working with string lists . . . 3-47 Loading and saving string lists. . . 3-48 Creating a new string list . . . 3-48 Manipulating strings in a list . . . 3-50 Associating objects with a string list. . . 3-52 Windows registry and INI files . . . 3-52 Using TIniFile (VCL only) . . . 3-52 Using TRegistry . . . 3-53 Using TRegIniFile . . . 3-53 Creating drawing spaces . . . 3-54 Printing . . . 3-54 Using streams . . . 3-55

Chapter 4

Common programming tasks 4-1

Understanding classes . . . . 4-1 Defining classes . . . . 4-2 Handling exceptions . . . . 4-4 Protecting blocks of code . . . . 4-4 Responding to exceptions. . . . 4-5 Exceptions and the flow of control. . . . . 4-6 Nesting exception responses . . . . 4-6 Protecting resource allocations. . . . 4-7

What kind of resources need

protection? . . . . 4-7 Creating a resource protection block. . . . 4-8 Handling RTL exceptions. . . . 4-9 What are RTL exceptions? . . . . 4-9 Creating an exception handler . . . 4-10 Exception handling statements. . . 4-11 Using the exception instance . . . 4-11 Scope of exception handlers . . . 4-12 Providing default exception

handlers . . . 4-12 Handling classes of exceptions . . . 4-13 Reraising the exception . . . 4-13 Handling component exceptions . . . 4-14 Exception handling with external

sources . . . 4-15 Silent exceptions. . . 4-15 Defining your own exceptions . . . 4-16 Declaring an exception object type. . . . 4-16 Raising an exception. . . 4-17 Using interfaces . . . 4-17 Interfaces as a language feature . . . 4-18

Implementing interfaces across

the hierarchy . . . 4-18

(5)

Using interfaces with procedures . . . . . 4-20 Implementing IInterface . . . . 4-20 TInterfacedObject . . . . 4-21 Using the as operator . . . . 4-21 Reusing code and delegation . . . . 4-22 Using implements for delegation . . . . . 4-22 Aggregation . . . . 4-23 Memory management of interface

objects . . . . 4-24 Using reference counting . . . . 4-24 Not using reference counting . . . . 4-25 Using interfaces in distributed

applications (VCL only) . . . . 4-26 Defining custom variants . . . . 4-27 Storing a custom variant type’s data . . . . . 4-28 Creating a class to enable the custom

variant type . . . . 4-28 Enabling casting . . . . 4-29 Implementing binary operations . . . . . 4-30 Implementing comparison operations . . 4-32 Implementing unary operations . . . . . 4-34 Copying and clearing custom

variants. . . . 4-34 Loading and saving custom variant

values. . . . 4-35 Using the TCustomVariantType

descendant . . . . 4-36 Writing utilities to work with a custom

variant type . . . . 4-36 Supporting properties and methods in

custom variants . . . . 4-37 Using TInvokeableVariantType . . . . 4-37 Using TPublishableVariantType. . . . 4-39 Working with strings . . . . 4-39 Character types . . . . 4-39 String types . . . . 4-40 Short strings . . . . 4-40 Long strings . . . . 4-41 WideString. . . . 4-41 PChar types . . . . 4-42 OpenString . . . . 4-42 Runtime library string handling routines . . 4-42 Wide character routines . . . . 4-43 Commonly used long string routines. . . 4-43 Declaring and initializing strings . . . . 4-46 Mixing and converting string types . . . . . 4-47 String to PChar conversions. . . . 4-47 String dependencies . . . . 4-47 Returning a PChar local variable . . . . . 4-48

Passing a local variable as a PChar . . . 4-48 Compiler directives for strings. . . 4-49 Strings and characters: related topics . . . . 4-50 Working with files . . . 4-50 Manipulating files . . . 4-50 Deleting a file. . . 4-50 Finding a file . . . 4-51 Renaming a file. . . 4-52 File date-time routines . . . 4-52 Copying a file . . . 4-53 File types with file I/O . . . 4-53 Using file streams . . . 4-54 Creating and opening files . . . 4-54 Using the file handle . . . 4-55 Reading and writing to files . . . 4-55 Reading and writing strings . . . 4-56 Seeking a file . . . 4-56 File position and size . . . 4-57 Copying . . . 4-57 Converting measurements . . . 4-58 Performing conversions . . . 4-58 Performing simple conversions . . . 4-58 Performing complex conversions . . . . 4-58 Adding new measurement types . . . 4-59

Creating a simple conversion family

and adding units . . . 4-59 Using a conversion function . . . 4-60 Using a class to manage

conversions . . . 4-62 Defining data types . . . 4-64

Chapter 5

Building applications, components,

and libraries 5-1

Creating applications . . . . 5-1 GUI applications. . . . 5-1 User interface models . . . . 5-2 SDI applications . . . . 5-2 MDI applications. . . . 5-2 Setting IDE, project, and compilation

options . . . . 5-3 Programming templates . . . . 5-3 Console applications . . . . 5-3 Service applications . . . . 5-4 Service threads . . . . 5-6 Service name properties. . . . 5-7 Debugging services . . . . 5-8 Creating packages and DLLs . . . . 5-9 When to use packages and DLLs . . . . 5-9

(6)

Writing database applications . . . . 5-10 Distributing database applications . . . . 5-11 Creating Web server applications . . . . 5-11 Using Web Broker . . . . 5-11 Creating WebSnap applications. . . . 5-13 Using InternetExpress . . . . 5-13 Creating Web Services applications . . . . . 5-13 Writing applications using COM. . . . 5-14 Using COM and DCOM . . . . 5-14 Using MTS and COM+ . . . . 5-14 Using data modules . . . . 5-15

Creating and editing standard data

modules . . . . 5-15 Naming a data module and its unit

file. . . . 5-16 Placing and naming components . . . . . 5-17 Using component properties and

events in a data module . . . . 5-17 Creating business rules in a data

module . . . . 5-18 Accessing a data module from a form . . . . 5-18 Adding a remote data module to an

application server project . . . . 5-19 Using the Object Repository . . . . 5-19 Sharing items within a project . . . . 5-19 Adding items to the Object Repository . . . 5-19 Sharing objects in a team environment . . . 5-20 Using an Object Repository item in

a project . . . . 5-20 Copying an item . . . . 5-20 Inheriting an item. . . . 5-20 Using an item . . . . 5-21 Using project templates . . . . 5-21 Modifying shared items . . . . 5-21 Specifying a default project, new form,

and main form . . . . 5-21 Enabling Help in applications . . . . 5-22 Help system interfaces . . . . 5-22 Implementing ICustomHelpViewer . . . . . 5-23 Communicating with the Help

Manager . . . . 5-23 Asking the Help Manager for

information . . . . 5-24 Displaying keyword-based Help . . . . 5-24 Displaying tables of contents . . . . 5-25 Implementing IExtendedHelpViewer . . . . 5-26 Implementing IHelpSelector . . . . 5-26 Registering Help system objects . . . . 5-27 Registering Help viewers . . . . 5-27

Registering Help selectors . . . 5-27 Using Help in a VCL Application . . . 5-28

How TApplication processes VCL

Help . . . 5-28 How VCL controls process Help. . . 5-28 Using Help in a CLX Application . . . 5-29

How TApplication processes CLX

Help . . . 5-29 How CLX controls process Help. . . 5-29 Calling a Help system directly . . . 5-30 Using IHelpSystem . . . 5-30 Customizing the IDE Help system . . . 5-30

Chapter 6

Developing the application user

interface 6-1

Controlling application behavior . . . . 6-1 Using the main form . . . . 6-1 Adding forms . . . . 6-2 Linking forms . . . . 6-2 Avoiding circular unit references. . . . 6-2 Hiding the main form. . . . 6-3 Working at the application level . . . . 6-3 Handling the screen . . . . 6-3 Managing layout . . . . 6-4 Responding to event notification . . . . 6-5 Using forms . . . . 6-5

Controlling when forms reside in

memory . . . . 6-6 Displaying an auto-created form. . . . 6-6 Creating forms dynamically . . . . 6-6 Creating modeless forms such as

windows . . . . 6-7 Using a local variable to create a form

instance . . . . 6-7 Passing additional arguments to forms . . . . 6-8 Retrieving data from forms. . . . 6-9 Retrieving data from modeless forms . . . 6-9 Retrieving data from modal forms. . . . 6-10 Reusing components and groups of

components . . . 6-12 Creating and using component templates . . . 6-13 Working with frames . . . 6-13 Creating frames . . . 6-14 Adding frames to the component

palette . . . 6-14 Using and modifying frames. . . 6-14 Sharing frames. . . 6-15

(7)

Organizing actions for toolbars and

menus . . . . 6-16 What is an action? . . . . 6-17 Setting up action bands . . . . 6-18 Creating toolbars and menus . . . . 6-18

Adding color, patterns, or pictures to menus, buttons, and toolbars . . . . 6-20 Adding icons to menus and toolbars . . . 6-21 Creating toolbars and menus that

users can customize. . . . 6-21 Hiding unused items and categories

in action bands . . . . 6-22 Using action lists . . . . 6-23 Setting up action lists . . . . 6-23 What happens when an action fires . . . . . 6-24 Responding with events . . . . 6-24 How actions find their targets . . . . 6-26 Updating actions . . . . 6-26 Predefined action classes . . . . 6-26 Writing action components . . . . 6-27 Registering actions . . . . 6-28 Creating and managing menus. . . . 6-29 Opening the Menu Designer . . . . 6-29 Building menus . . . . 6-31 Naming menus . . . . 6-31 Naming the menu items . . . . 6-31 Adding, inserting, and deleting

menu items . . . . 6-32 Adding separator bars . . . . 6-32 Specifying accelerator keys and

keyboard shortcuts . . . . 6-33 Creating submenus. . . . 6-33

Creating submenus by demoting

existing menus . . . . 6-34 Moving menu items . . . . 6-34 Adding images to menu items . . . . 6-35 Viewing the menu . . . . 6-35 Editing menu items in the Object

Inspector . . . . 6-35 Using the Menu Designer context

menu . . . . 6-36 Commands on the context menu . . . . . 6-36 Switching between menus at design

time . . . . 6-37 Using menu templates . . . . 6-37 Saving a menu as a template . . . . 6-38

Naming conventions for template

menu items and event handlers . . . . . 6-39 Manipulating menu items at runtime . . . . 6-40

Merging menus . . . 6-40 Specifying the active menu: Menu

property . . . 6-40 Determining the order of merged menu

items: GroupIndex property . . . 6-40 Importing resource files . . . 6-41 Designing toolbars and cool bars . . . 6-41

Adding a toolbar using a panel

component . . . 6-42 Adding a speed button to a panel . . . . 6-43 Assigning a speed button’s glyph . . . . 6-43 Setting the initial condition of a

speed button . . . 6-43 Creating a group of speed buttons . . . . 6-44 Allowing toggle buttons . . . 6-44 Adding a toolbar using the toolbar

component . . . 6-44 Adding a tool button . . . 6-45 Assigning images to tool buttons . . . . 6-45 Setting tool button appearance and

initial conditions . . . 6-46 Creating groups of tool buttons . . . 6-46 Allowing toggled tool buttons . . . 6-46 Adding a cool bar component . . . 6-47

Setting the appearance of the

cool bar . . . 6-47 Responding to clicks . . . 6-48 Assigning a menu to a tool button . . . . 6-48 Adding hidden toolbars . . . 6-48 Hiding and showing toolbars . . . 6-48 Demo programs . . . 6-49

Chapter 7

Working with controls 7-1

Implementing drag-and-drop in controls . . . . 7-1 Starting a drag operation . . . . 7-1 Accepting dragged items . . . . 7-2 Dropping items . . . . 7-2 Ending a drag operation . . . . 7-3 Customizing drag and drop with a

drag object . . . . 7-3 Changing the drag mouse pointer. . . . 7-4 Implementing drag-and-dock in controls . . . . 7-4

Making a windowed control a docking

site. . . . 7-4 Making a control a dockable child. . . . 7-4 Controlling how child controls are

docked . . . . 7-5

(8)

Controlling how child controls are

undocked . . . 7-6 Controlling how child controls respond

to drag-and-dock operations . . . 7-6 Working with text in controls. . . 7-6 Setting text alignment . . . 7-7 Adding scroll bars at runtime . . . 7-7 Adding the clipboard object. . . 7-8 Selecting text . . . 7-8 Selecting all text . . . 7-9 Cutting, copying, and pasting text . . . 7-9 Deleting selected text . . . 7-9 Disabling menu items . . . . 7-10 Providing a pop-up menu . . . . 7-10 Handling the OnPopup event. . . . 7-11 Adding graphics to controls . . . . 7-11

Indicating that a control is

owner-drawn . . . . 7-12 Adding graphical objects to a string list . . . 7-12 Adding images to an application . . . . . 7-13 Adding images to a string list . . . . 7-13 Drawing owner-drawn items . . . . 7-13 Sizing owner-draw items . . . . 7-14 Drawing owner-draw items. . . . 7-15

Chapter 8

Working with graphics and

multimedia 8-1

Overview of graphics programming. . . 8-1 Refreshing the screen . . . 8-2 Types of graphic objects . . . 8-3 Common properties and methods of

Canvas . . . 8-4 Using the properties of the Canvas

object . . . 8-5 Using pens. . . 8-5 Using brushes . . . 8-8 Reading and setting pixels . . . 8-9 Using Canvas methods to draw graphic

objects . . . 8-9 Drawing lines and polylines. . . . 8-10 Drawing shapes . . . . 8-11 Handling multiple drawing objects in

your application . . . . 8-12 Keeping track of which drawing tool

to use . . . . 8-12 Changing the tool with speed buttons . . 8-13 Using drawing tools . . . . 8-13 Drawing on a graphic . . . . 8-16

Making scrollable graphics . . . 8-16 Adding an image control . . . 8-17 Loading and saving graphics files . . . 8-18 Loading a picture from a file . . . 8-19 Saving a picture to a file. . . 8-19 Replacing the picture . . . 8-20 Using the clipboard with graphics . . . 8-21 Copying graphics to the clipboard. . . . 8-21 Cutting graphics to the clipboard . . . . 8-21 Pasting graphics from the clipboard . . . 8-22 Rubber banding example . . . 8-23 Responding to the mouse . . . 8-23 Responding to a mouse-down action . . 8-24 Adding a field to a form object to track

mouse actions . . . 8-26 Refining line drawing . . . 8-27 Working with multimedia . . . 8-28

Adding silent video clips to an

application . . . 8-29 Example of adding silent video clips . . 8-30 Adding audio and/or video clips to an

application . . . 8-30 Example of adding audio and/or video

clips (VCL only) . . . 8-32

Chapter 9

Writing multi-threaded applications 9-1

Defining thread objects . . . . 9-1 Initializing the thread . . . . 9-2 Assigning a default priority . . . . 9-2 Indicating when threads are freed . . . . . 9-3 Writing the thread function . . . . 9-4 Using the main VCL/CLX thread . . . . . 9-4 Using thread-local variables . . . . 9-5 Checking for termination by other

threads . . . . 9-5 Handling exceptions in the thread

function . . . . 9-6 Writing clean-up code. . . . 9-6 Coordinating threads . . . . 9-7 Avoiding simultaneous access . . . . 9-7 Locking objects. . . . 9-7 Using critical sections . . . . 9-7 Using the multi-read exclusive-write

synchronizer . . . . 9-8 Other techniques for sharing memory. . . 9-8 Waiting for other threads . . . . 9-9

Waiting for a thread to finish

executing . . . . 9-9

(9)

Waiting for a task to be completed . . . . 9-9 Executing thread objects . . . . 9-10 Overriding the default priority . . . . 9-11 Starting and stopping threads . . . . 9-11 Debugging multi-threaded applications . . . . 9-12

Chapter 10

Using CLX for cross-platform

development 10-1

Creating cross-platform applications . . . . 10-1 Porting VCL applications to CLX . . . . 10-2 Porting techniques . . . . 10-3 Platform-specific ports . . . . 10-3 Cross-platform ports . . . . 10-3 Windows emulation ports . . . . 10-3 Porting your application. . . . 10-4 CLX versus VCL . . . . 10-5 What CLX does differently . . . . 10-6 Look and feel . . . . 10-6 Styles . . . . 10-6 Variants . . . . 10-7 Registry . . . . 10-7 Other differences . . . . 10-7 Missing in CLX . . . . 10-8 Features that will not port . . . . 10-8 CLX and VCL unit comparison . . . . 10-9 Differences in CLX object

constructors . . . 10-13 Sharing source files between

Windows and Linux . . . 10-13 Environmental differences between

Windows and Linux . . . 10-14 Directory structure on Linux . . . 10-16 Writing portable code . . . 10-17 Using conditional directives . . . 10-18 Terminating conditional directives . . . 10-19 Emitting messages . . . 10-20 Including inline assembler code. . . 10-20 Messages and system events . . . 10-21 Programming differences on Linux . . . . 10-22 Cross-platform database applications . . . 10-23 dbExpress differences . . . 10-23 Component-level differences . . . 10-24 User interface-level differences . . . 10-25 Porting database applications to

Linux . . . 10-25 Updating data in dbExpress

applications . . . 10-27 Cross-platform Internet applications . . . 10-29

Porting Internet applications to Linux . . 10-29

Chapter 11

Working with packages and

components 11-1

Why use packages? . . . 11-2 Packages and standard DLLs . . . 11-2 Runtime packages . . . 11-2 Using packages in an application . . . 11-3 Dynamically loading packages . . . 11-4 Deciding which runtime packages

to use . . . 11-4 Custom packages . . . 11-4 Design-time packages . . . 11-5 Installing component packages . . . 11-5 Creating and editing packages . . . 11-6 Creating a package . . . 11-6 Editing an existing package . . . 11-7 Editing package source files manually . . . 11-8 Understanding the structure of a

package . . . 11-8 Naming packages . . . 11-8 Requires clause. . . 11-8 Contains clause. . . 11-9 Compiling packages . . . .11-10

Package-specific compiler

directives . . . .11-10 Using the command-line compiler

and linker . . . .11-12 Package files created by a successful

compilation . . . .11-12 Deploying packages . . . .11-13

Deploying applications that use

packages . . . .11-13 Distributing packages to other

developers . . . .11-13 Package collection files . . . .11-13

Chapter 12

Creating international applications 12-1

Internationalization and localization . . . 12-1 Internationalization . . . 12-1 Localization . . . 12-2 Internationalizing applications . . . 12-2 Enabling application code . . . 12-2 Character sets . . . 12-2 OEM and ANSI character sets . . . 12-3 Multibyte character sets. . . 12-3 Wide characters . . . 12-4

(10)

Including bi-directional functionality in applications . . . . 12-4 BiDiMode property . . . . 12-6 Locale-specific features. . . . 12-8 Designing the user interface. . . . 12-9 Text . . . . 12-9 Graphic images . . . . 12-9 Formats and sort order . . . 12-10 Keyboard mappings . . . 12-10 Isolating resources . . . 12-10 Creating resource DLLs . . . 12-10 Using resource DLLs . . . 12-12 Dynamic switching of resource DLLs . . . 12-13 Localizing applications . . . 12-13 Localizing resources . . . 12-13

Chapter 13

Deploying applications 13-1

Deploying general applications . . . . 13-1 Using installation programs. . . . 13-2 Identifying application files . . . . 13-2 Application files. . . . 13-3 Package files . . . . 13-3 Merge modules . . . . 13-3 ActiveX controls . . . . 13-5 Helper applications. . . . 13-5 DLL locations . . . . 13-5 Deploying CLX applications . . . . 13-6 Deploying database applications. . . . 13-6

Deploying dbExpress database

applications . . . . 13-7 Deploying BDE applications . . . . 13-8 Borland Database Engine . . . . 13-8 SQL Links . . . . 13-8 Deploying multi-tiered database

applications (DataSnap) . . . . 13-9 Deploying Web applications . . . . 13-9 Deployment on Apache . . . 13-10 Programming for varying host

environments . . . 13-11 Screen resolutions and color depths . . . . 13-11

Considerations when not

dynamically resizing . . . 13-11 Considerations when dynamically

resizing forms and controls . . . 13-12 Accommodating varying color

depths . . . 13-13 Fonts . . . 13-13 Operating systems versions . . . 13-14

Software license requirements. . . 13-14 DEPLOY . . . 13-14 README . . . 13-15 No-nonsense license agreement . . . 13-15 Third-party product documentation . . . 13-15

Part II

Developing database applications

Chapter 14

Designing database applications 14-1

Using databases . . . 14-1 Types of databases. . . 14-2 Database security . . . 14-3 Transactions . . . 14-4 Referential integrity, stored procedures,

and triggers. . . 14-5 Database architecture. . . 14-5 General structure . . . 14-6 The user interface form . . . 14-6 The data module . . . 14-6 Connecting directly to a database

server . . . 14-7 Using a dedicated file on disk . . . 14-9 Connecting to another dataset . . . 14-10

Connecting a client dataset to another dataset in the same application. . . . .14-11 Using a multi-tiered architecture. . . . 14-12 Combining approaches . . . 14-14 Designing the user interface . . . 14-15 Analyzing data . . . 14-15 Writing reports. . . 14-16

Chapter 15

Using data controls 15-1

Using common data control features . . . 15-2 Associating a data control with a

dataset . . . 15-3 Changing the associated dataset

at runtime . . . 15-3 Enabling and disabling the data

source . . . 15-4 Responding to changes mediated by

the data source . . . 15-4 Editing and updating data . . . 15-5

Enabling editing in controls on user

entry . . . 15-5 Editing data in a control. . . 15-5

(11)

Disabling and enabling data display . . . . . 15-6 Refreshing data display . . . . 15-6 Enabling mouse, keyboard, and timer

events . . . . 15-7 Choosing how to organize the data . . . . 15-7 Displaying a single record. . . . 15-7 Displaying data as labels. . . . 15-8 Displaying and editing fields in an

edit box. . . . 15-8 Displaying and editing text in a

memo control . . . . 15-8 Displaying and editing text in a rich

edit memo control. . . . 15-9 Displaying and editing graphics

fields in an image control . . . . 15-9 Displaying and editing data in list

and combo boxes . . . 15-10 Handling Boolean field values with

check boxes . . . 15-12 Restricting field values with radio

controls . . . 15-13 Displaying multiple records. . . 15-14 Viewing and editing data with TDBGrid . . . 15-15

Using a grid control in its default

state . . . 15-15 Creating a customized grid . . . 15-16 Understanding persistent columns . . . 15-16 Creating persistent columns . . . 15-17 Deleting persistent columns . . . 15-18 Arranging the order of persistent

columns . . . 15-19 Setting column properties at design

time . . . 15-19 Defining a lookup list column . . . 15-20 Putting a button in a column . . . 15-21 Restoring default values to a

column . . . 15-21 Displaying ADT and array fields . . . 15-21 Setting grid options . . . 15-23 Editing in the grid . . . 15-25 Controlling grid drawing . . . 15-25 Responding to user actions at runtime. . . 15-25 Creating a grid that contains other

data-aware controls . . . 15-26 Navigating and manipulating records. . . 15-28

Choosing navigator buttons to

display . . . 15-28 Hiding and showing navigator

buttons at design time . . . 15-29

Hiding and showing navigator

buttons at runtime . . . 15-29 Displaying fly-over help . . . 15-30 Using a single navigator for multiple

datasets . . . 15-30

Chapter 16

Using decision support

components 16-1

Overview . . . 16-1 About crosstabs . . . 16-2 One-dimensional crosstabs. . . 16-2 Multidimensional crosstabs . . . 16-3 Guidelines for using decision support

components . . . 16-3 Using datasets with decision support

components . . . 16-4 Creating decision datasets with TQuery

or TTable . . . 16-5 Creating decision datasets with the

Decision Query editor. . . 16-6 Using decision cubes . . . 16-7 Decision cube properties and events . . . . 16-7 Using the Decision Cube editor . . . 16-7

Viewing and changing dimension

settings . . . 16-8 Setting the maximum available

dimensions and summaries. . . 16-8 Viewing and changing design

options . . . 16-8 Using decision sources . . . 16-9 Properties and events . . . 16-9 Using decision pivots. . . 16-9 Decision pivot properties. . . 16-10 Creating and using decision grids . . . 16-10 Creating decision grids . . . 16-10 Using decision grids . . . .16-11

Opening and closing decision grid

fields. . . .16-11 Reorganizing rows and columns in

decision grids. . . .16-11 Drilling down for detail in

decision grids. . . .16-11 Limiting dimension selection in

decision grids. . . 16-12 Decision grid properties . . . 16-12 Creating and using decision graphs . . . 16-13 Creating decision graphs . . . 16-13 Using decision graphs . . . 16-13

(12)

The decision graph display . . . 16-15 Customizing decision graphs . . . 16-15

Setting decision graph template

defaults. . . 16-16 Customizing decision graph

series . . . 16-17 Decision support components at

runtime . . . 16-18 Decision pivots at runtime . . . 16-18 Decision grids at runtime . . . 16-18 Decision graphs at runtime . . . 16-19 Decision support components and

memory control . . . 16-19 Setting maximum dimensions,

summaries, and cells . . . 16-19 Setting dimension state . . . 16-19 Using paged dimensions . . . 16-20

Chapter 17

Connecting to databases 17-1

Using implicit connections . . . . 17-2 Controlling connections . . . . 17-2 Connecting to a database server . . . . 17-3 Disconnecting from a database server . . . . 17-3 Controlling server login . . . . 17-4 Managing transactions . . . . 17-5 Starting a transaction . . . . 17-6 Ending a transaction . . . . 17-7 Ending a successful transaction . . . . 17-8 Ending an unsuccessful transaction . . . 17-8 Specifying the transaction isolation

level . . . . 17-9 Sending commands to the server . . . 17-10 Working with associated datasets . . . 17-11

Closing all datasets without dis-

connecting from the server . . . 17-12 Iterating through the associated

datasets . . . 17-12 Obtaining metadata . . . 17-12 Listing available tables. . . 17-13 Listing the fields in a table . . . 17-13 Listing available stored procedures . . . . 17-13 Listing available indexes . . . 17-14 Listing stored procedure parameters. . . . 17-14

Chapter 18

Understanding datasets 18-1

Using TDataSet descendants . . . . 18-2 Determining dataset states . . . . 18-3

Opening and closing datasets . . . 18-4 Navigating datasets. . . 18-5 Using the First and Last methods . . . 18-6 Using the Next and Prior methods . . . 18-6 Using the MoveBy method . . . 18-7 Using the Eof and Bof properties . . . 18-7 Eof . . . 18-7 Bof . . . 18-8 Marking and returning to records . . . 18-9 The Bookmark property. . . 18-9 The GetBookmark method . . . 18-9 The GotoBookmark and Bookmark

Valid methods . . . 18-9 The CompareBookmarks method . . . . 18-9 The FreeBookmark method . . . 18-9 A bookmarking example . . . 18-10 Searching datasets . . . 18-10 Using Locate . . . 18-10 Using Lookup . . . .18-11 Displaying and editing a subset of data

using filters . . . 18-12 Enabling and disabling filtering . . . 18-12 Creating filters . . . 18-13 Setting the Filter property. . . 18-13 Writing an OnFilterRecord event

handler . . . 18-14 Switching filter event handlers at

runtime . . . 18-15 Setting filter options. . . 18-15 Navigating records in a filtered

dataset . . . 18-16 Modifying data . . . 18-16 Editing records. . . 18-17 Adding new records . . . 18-18 Inserting records . . . 18-19 Appending records . . . 18-19 Deleting records . . . 18-19 Posting data . . . 18-20 Canceling changes. . . 18-20 Modifying entire records . . . 18-21 Calculating fields . . . 18-22 Types of datasets . . . 18-23 Using table-type datasets . . . 18-24

Advantages of using table-type

datasets . . . 18-25 Sorting records with indexes . . . 18-25

Obtaining information about

indexes . . . 18-26

(13)

Specifying an index with

IndexName . . . 18-26 Creating an index with Index

FieldNames . . . 18-27 Using Indexes to search for records . . . . 18-27

Executing a search with Goto

methods . . . 18-28 Executing a search with Find

methods . . . 18-28 Specifying the current record after a

successful search . . . 18-29 Searching on partial keys . . . 18-29 Repeating or extending a search . . . . 18-29 Limiting records with ranges . . . 18-30

Understanding the differences between ranges and filters . . . 18-30 Specifying Ranges . . . 18-30 Modifying a range . . . 18-33 Applying or canceling a range . . . 18-33 Creating master/detail relationships. . . . 18-34

Making the table a detail of another

dataset . . . 18-34 Using nested detail tables . . . 18-36 Controlling Read/write access to

tables . . . 18-37 Creating and deleting tables . . . 18-37 Creating tables . . . 18-37 Deleting tables . . . 18-40 Emptying tables . . . 18-40 Synchronizing tables . . . 18-40 Using query-type datasets . . . 18-41 Specifying the query . . . 18-42

Specifying a query using the SQL

property . . . 18-42 Specifying a query using the

CommandText property . . . 18-43 Using parameters in queries . . . 18-43

Supplying parameters at design

time . . . 18-44 Supplying parameters at runtime . . . . 18-45 Establishing master/detail relationships

using parameters . . . 18-46 Preparing queries. . . 18-47 Executing queries that don’t return a

result set . . . 18-47 Using unidirectional result sets . . . 18-48 Using stored procedure-type datasets . . . 18-48

Working with stored procedure

parameters. . . 18-50

Setting up parameters at design

time . . . 18-50 Using parameters at runtime . . . 18-52 Preparing stored procedures . . . 18-52 Executing stored procedures that don’t

return a result set . . . 18-53 Fetching multiple result sets . . . 18-53

Chapter 19

Working with field components 19-1

Dynamic field components . . . 19-2 Persistent field components . . . 19-3 Creating persistent fields . . . 19-4 Arranging persistent fields . . . 19-5 Defining new persistent fields . . . 19-5 Defining a data field . . . 19-6 Defining a calculated field . . . 19-7 Programming a calculated field . . . 19-7 Defining a lookup field . . . 19-8 Defining an aggregate field . . . 19-10 Deleting persistent field components . . . 19-10 Setting persistent field properties

and events . . . 19-10 Setting display and edit properties

at design time. . . .19-11 Setting field component properties

at runtime . . . 19-12 Creating attribute sets for field

components . . . 19-12 Associating attribute sets with field

components . . . 19-13 Removing attribute associations . . . . 19-14 Controlling and masking user

input . . . 19-14 Using default formatting for numeric,

date, and time fields . . . 19-14 Handling events . . . 19-15 Working with field component methods

at runtime . . . 19-16 Displaying, converting, and accessing

field values. . . 19-17 Displaying field component values in

standard controls . . . 19-17 Converting field values . . . 19-17 Accessing field values with the default

dataset property . . . 19-19 Accessing field values with a dataset’s

Fields property. . . 19-19

(14)

Accessing field values with a dataset’s

FieldByName method . . . 19-20 Setting a default value for a field. . . 19-20 Working with constraints . . . 19-21 Creating a custom constraint . . . 19-21 Using server constraints . . . 19-21 Using object fields . . . 19-22 Displaying ADT and array fields . . . 19-23 Working with ADT fields . . . 19-23 Using persistent field components . . . 19-24 Using the dataset’s FieldByName

method . . . 19-24 Using the dateset’s FieldValues

property . . . 19-24 Using the ADT field’s FieldValues

property . . . 19-24 Using the ADT field’s Fields

property . . . 19-25 Working with array fields . . . 19-25 Using persistent fields . . . 19-25 Using the array field’s FieldValues

property . . . 19-25 Using the array field’s Fields

property . . . 19-26 Working with dataset fields . . . 19-26 Displaying dataset fields . . . 19-26 Accessing data in a nested dataset . . . 19-26 Working with reference fields . . . 19-27 Displaying reference fields. . . 19-27 Accessing data in a reference field . . . 19-27

Chapter 20

Using the Borland Database

Engine 20-1

BDE-based architecture . . . . 20-1 Using BDE-enabled datasets . . . . 20-2

Associating a dataset with database

and session connections . . . . 20-3 Caching BLOBs . . . . 20-4 Obtaining a BDE handle . . . . 20-4 Using TTable . . . . 20-4

Specifying the table type for local

tables . . . . 20-5 Controlling read/write access to

local tables . . . . 20-6 Specifying a dBASE index file . . . . 20-6 Renaming local tables . . . . 20-7 Importing data from another table . . . . 20-8 Using TQuery. . . . 20-8

Creating heterogeneous queries . . . 20-9 Obtaining an editable result set . . . . 20-10 Updating read-only result sets . . . .20-11 Using TStoredProc . . . .20-11 Binding parameters . . . 20-12 Working with Oracle overloaded

stored procedures . . . 20-12 Connecting to databases with

TDatabase . . . 20-12 Associating a database component

with a session. . . 20-13 Understanding database and session

component interactions . . . 20-13 Identifying the database . . . 20-13 Opening a connection using

TDatabase . . . 20-15 Using database components in

data modules . . . 20-16 Managing database sessions . . . 20-16 Activating a session . . . 20-17 Specifying default database

connection behavior . . . 20-18 Managing database connections . . . . 20-19 Working with password-protected

Paradox and dBASE tables . . . 20-21 Specifying Paradox directory

locations. . . 20-24 Working with BDE aliases . . . 20-24 Retrieving information about a

session . . . 20-26 Creating additional sessions . . . 20-27 Naming a session . . . 20-28 Managing multiple sessions . . . 20-28 Using transactions with the BDE . . . 20-30 Using passthrough SQL . . . 20-30 Using local transactions . . . 20-31 Using the BDE to cache updates . . . 20-32 Enabling BDE-based cached updates . . . 20-33 Applying BDE-based cached updates. . . 20-33

Applying cached updates using

a database . . . 20-35 Applying cached updates with dataset

component methods . . . 20-35 Creating an OnUpdateRecord

event handler . . . 20-36 Handling cached update errors . . . . 20-37 Using update objects to update a

dataset . . . 20-39

(15)

Creating SQL statements for update

components . . . 20-40 Using multiple update objects. . . 20-43 Executing the SQL statements . . . 20-44 Using TBatchMove. . . 20-47 Creating a batch move component . . . 20-47 Specifying a batch move mode . . . 20-49 Appending records . . . 20-49 Updating records . . . 20-49 Appending and updating

records . . . 20-49 Copying datasets . . . 20-49 Deleting records. . . 20-50 Mapping data types . . . 20-50 Executing a batch move . . . 20-51 Handling batch move errors . . . 20-51 The Data Dictionary . . . 20-52 Tools for working with the BDE . . . 20-53

Chapter 21

Working with ADO components 21-1

Overview of ADO components . . . . 21-1 Connecting to ADO data stores . . . . 21-2

Connecting to a data store using

TADOConnection. . . . 21-3 Accessing the connection object . . . . 21-4 Fine-tuning a connection . . . . 21-4 Forcing asynchronous connections . . . . 21-5 Controlling timeouts . . . . 21-5 Indicating the types of operations the

connection supports . . . . 21-6 Specifying whether the connection

automatically initiates transactions . . . 21-6 Accessing the connection’s commands . . . 21-7 ADO connection events . . . . 21-7

Events when establishing a

connection . . . . 21-7 Events when disconnecting . . . . 21-8 Events when managing transactions . . . 21-8 Other events . . . . 21-8 Using ADO datasets . . . . 21-9

Connecting an ADO dataset to a

data store . . . . 21-9 Working with record sets . . . 21-10 Filtering records based on

bookmarks . . . 21-10 Fetching records asynchronously . . . . 21-11 Using batch updates . . . 21-12

Loading data from and saving

data to files . . . 21-14 Using TADODataSet . . . 21-15 Using Command objects . . . 21-16 Specifying the command . . . 21-17 Using the Execute method . . . 21-17 Canceling commands . . . 21-18 Retrieving result sets with commands . . 21-18 Handling command parameters . . . 21-19

Chapter 22

Using unidirectional datasets 22-1

Types of unidirectional datasets . . . 22-2 Connecting to the database server . . . 22-2 Setting up TSQLConnection . . . 22-3 Identifying the driver . . . 22-3 Specifying connection parameters . . . . 22-4 Naming a connection description . . . . 22-4 Using the Connection Editor . . . 22-5 Specifying what data to display . . . 22-5 Representing the results of a query . . . 22-6 Representing the records in a table . . . 22-6

Representing a table using

TSQLDataSet . . . 22-6 Representing a table using

TSQLTable. . . 22-7 Representing the results of a stored

procedure . . . 22-7 Fetching the data . . . 22-8 Preparing the dataset . . . 22-8 Fetching multiple datasets . . . 22-9 Executing commands that do not return

records . . . 22-9 Specifying the command to execute. . . 22-9 Executing the command . . . 22-10 Creating and modifying server metadata. 22-10 Setting up master/detail linked cursors . . . 22-12 Accessing schema information . . . 22-12

Fetching metadata into a unidirectional dataset . . . 22-12

Fetching data after using the dataset for metadata . . . 22-13 The structure of metadata datasets . . 22-13 Debugging dbExpress applications . . . 22-17

Using TSQLMonitor to monitor SQL

commands . . . 22-17 Using a callback to monitor SQL

commands . . . 22-18

(16)

Chapter 23

Using client datasets 23-1

Working with data using a client dataset . . . . 23-2 Navigating data in client datasets . . . . 23-2 Limiting what records appear. . . . 23-2 Editing data . . . . 23-5 Undoing changes . . . . 23-5 Saving changes . . . . 23-6 Constraining data values . . . . 23-6 Specifying custom constraints. . . . 23-7 Sorting and indexing. . . . 23-7 Adding a new index . . . . 23-8 Deleting and switching indexes . . . . 23-9 Using indexes to group data. . . . 23-9 Representing calculated values . . . 23-10

Using internally calculated fields in

client datasets . . . 23-10 Using maintained aggregates . . . 23-11 Specifying aggregates . . . 23-11 Aggregating over groups of

records . . . 23-12 Obtaining aggregate values . . . 23-13 Copying data from another dataset . . . . 23-13 Assigning data directly. . . 23-13 Cloning a client dataset cursor . . . 23-14 Adding application-specific information

to the data . . . 23-14 Using a client dataset to cache updates . . . . 23-15 Overview of using cached updates. . . 23-16 Choosing the type of dataset for caching

updates . . . 23-17 Indicating what records are modified . . . 23-18 Updating records . . . 23-19 Applying updates. . . 23-19 Intervening as updates are applied . . . 23-20 Reconciling update errors . . . 23-22 Using a client dataset with a provider . . . 23-23 Specifying a provider . . . 23-24 Requesting data from the source dataset

or document. . . 23-25 Incremental fetching . . . 23-25 Fetch-on-demand . . . 23-26 Getting parameters from the source

dataset . . . 23-26 Passing parameters to the source

dataset . . . 23-27 Sending query or stored procedure

parameters . . . 23-27 Limiting records with parameters . . . 23-28

Handling constraints from the server . . . 23-28 Refreshing records. . . 23-29 Communicating with providers using

custom events . . . 23-30 Overriding the source dataset . . . 23-31 Using a client dataset with file-based data . . 23-31 Creating a new dataset . . . 23-32 Loading data from a file or stream . . . . 23-32 Merging changes into data . . . 23-33 Saving data to a file or stream . . . 23-33

Chapter 24

Using provider components 24-1

Determining the source of data . . . 24-2 Using a dataset as the source of the

data . . . 24-2 Using an XML document as the source

of the data . . . 24-2 Communicating with the client dataset . . . . 24-3 Choosing how to apply updates using a

dataset provider . . . 24-4 Controlling what information is included

in data packets. . . 24-4 Specifying what fields appear in

data packets . . . 24-4 Setting options that influence the

data packets . . . 24-5 Adding custom information to

data packets . . . 24-6 Responding to client data requests . . . 24-7 Responding to client update requests . . . 24-8

Editing delta packets before updating the database . . . 24-9 Influencing how updates are applied . . . . 24-9 Screening individual updates . . . .24-11 Resolving update errors on the

provider. . . .24-11 Applying updates to datasets that do

not represent a single table . . . .24-11 Responding to client-generated events . . . . 24-12 Handling server constraints . . . 24-12

Chapter 25

Creating multi-tiered applications 25-1

Advantages of the multi-tiered database

model . . . 25-2 Understanding provider-based multi-tiered

applications . . . 25-2 Overview of a three-tiered application . . . 25-3

(17)

The structure of the client application . . . . 25-4 The structure of the application server. . . . 25-5

The contents of the remote data

module . . . . 25-6 Using transactional data modules . . . . 25-6 Pooling remote data modules . . . . 25-8 Choosing a connection protocol . . . . 25-8 Using DCOM connections . . . . 25-8 Using Socket connections . . . . 25-9 Using Web connections. . . . 25-9 Using SOAP connections. . . 25-10 Using CORBA connections . . . 25-10 Building a multi-tiered application . . . 25-11 Creating the application server. . . 25-11 Setting up the remote data module. . . 25-13

Configuring TRemoteData-

Module . . . 25-13 Configuring TMTSDataModule . . . 25-14 Configuring TSoapDataModule. . . 25-15 Configuring TCorbaDataModule . . . . 25-15 Extending the application server’s

interface . . . 25-16 Adding callbacks to the application

server’s interface . . . 25-17 Extending a transactional application

server’s interface . . . 25-18 Managing transactions in multi-tiered

applications . . . 25-18 Supporting master/detail

relationships. . . 25-19 Supporting state information in remote

data modules . . . 25-19 Using multiple remote data modules . . . 25-21 Registering the application server . . . 25-22 Creating the client application . . . 25-23 Connecting to the application server. . . . 25-23

Specifying a connection using

DCOM . . . 25-24 Specifying a connection using

sockets . . . 25-25 Specifying a connection using

HTTP . . . 25-26 Specifying a connection using

SOAP . . . 25-26 Specifying a connection using

CORBA . . . 25-27 Brokering connections . . . 25-27 Managing server connections . . . 25-28 Connecting to the server . . . 25-28

Dropping or changing a server

connection . . . 25-28 Calling server interfaces . . . 25-29 Connecting to an application server

that uses multiple data modules . . . 25-30 Writing Web-based client applications . . . . 25-31

Distributing a client application as

an ActiveX control . . . 25-32 Creating an Active Form for the client

application . . . 25-33 Building Web applications using

InternetExpress . . . 25-33 Building an InternetExpress

application . . . 25-34 Using the javascript libraries . . . 25-35 Granting permission to access and

launch the application server . . . 25-36 Using an XML broker . . . 25-36 Fetching XML data packets . . . 25-36 Applying updates from XML delta

packets . . . 25-37 Creating Web pages with an InternetExpress

page producer . . . 25-38 Using the Web page editor . . . 25-39 Setting Web item properties . . . 25-40 Customizing the InternetExpress page

producer template . . . 25-41

Chapter 26

Using XML in database

applications 26-1

Defining transformations . . . 26-1 Mapping between XML nodes and data

packet fields . . . 26-2 Using XMLMapper . . . 26-4

Loading an XML schema or data

packet . . . 26-4 Defining mappings . . . 26-4 Generating transformation files . . . 26-5 Converting XML documents into data

packets . . . 26-6 Specifying the source XML document . . . 26-6 Specifying the transformation . . . 26-7 Obtaining the resulting data packet . . . 26-7 Converting user-defined nodes . . . 26-7 Using an XML document as the source for a

provider . . . 26-8 Using an XML document as the client of

a provider . . . 26-9

(18)

Fetching an XML document from

a provider . . . . 26-9 Applying updates from an XML

document to a provider . . . 26-10

Part III

Writing Internet applications

Chapter 27

Creating Internet applications 27-1

About Web Broker and WebSnap . . . . 27-1 Terminology and standards. . . . 27-2 Parts of a Uniform Resource Locator. . . . . 27-3 URI vs. URL . . . . 27-3 HTTP request header information . . . . 27-4 HTTP server activity. . . . 27-4 Composing client requests . . . . 27-4 Serving client requests . . . . 27-5 Responding to client requests . . . . 27-5 Types of Web server applications . . . . 27-6 ISAPI and NSAPI . . . . 27-6 Apache . . . . 27-6 CGI stand-alone. . . . 27-6 Win-CGI stand-alone . . . . 27-7 Debugging server applications . . . . 27-7 Using the Web Application Debugger . . . . 27-7

Launching your application with the Web Application Debugger . . . . 27-7 Converting your application to another

type of Web server application . . . . . 27-8 Debugging Web applications that are

DLLs . . . . 27-8 Debugging under Windows NT. . . . 27-9 Debugging under Windows 2000 . . . . . 27-9

Chapter 28

Using Web Broker 28-1

Creating Web server applications with

Web Broker . . . . 28-1 The Web module . . . . 28-2 The Web Application object . . . . 28-3 The structure of a Web Broker application . . . 28-3 The Web dispatcher . . . . 28-4 Adding actions to the dispatcher . . . . 28-4 Dispatching request messages . . . . 28-5 Action items . . . . 28-5 Determining when action items fire . . . . . 28-6 The target URL . . . . 28-6

The request method type . . . 28-6 Enabling and disabling action items. . . 28-6 Choosing a default action item . . . 28-7 Responding to request messages with

action items. . . 28-7 Sending the response . . . 28-8 Using multiple action items . . . 28-8 Accessing client request information . . . 28-8

Properties that contain request header

information. . . 28-9 Properties that identify the target . . . . 28-9 Properties that describe the Web

client . . . 28-9 Properties that identify the purpose

of the request . . . 28-9 Properties that describe the expected

response . . . 28-10 Properties that describe the

content. . . 28-10 The content of HTTP request

messages . . . 28-10 Creating HTTP response messages . . . 28-10 Filling in the response header . . . .28-11 Indicating the response status . . . .28-11 Indicating the need for client

action . . . .28-11 Describing the server application . . . 28-12 Describing the content . . . 28-12 Setting the response content . . . 28-12 Sending the response . . . 28-12 Generating the content of response

messages . . . 28-13 Using page producer components. . . 28-13 HTML templates . . . 28-13 Specifying the HTML template. . . 28-14 Converting HTML-transparent

tags . . . 28-14 Using page producers from an

action item . . . 28-15 Chaining page producers

together . . . 28-16 Using database information in

responses . . . 28-17 Adding a session to the Web module . . . 28-17 Representing database information

in HTML . . . 28-18 Using dataset page producers . . . 28-18 Using table producers . . . 28-18 Specifying the table attributes . . . 28-18

(19)

Specifying the row attributes . . . 28-19 Specifying the columns. . . 28-19 Embedding tables in HTML

documents . . . 28-19 Setting up a dataset table

producer . . . 28-20 Setting up a query table producer . . . 28-20

Chapter 29

Using WebSnap 29-1

Creating Web server applications with

WebSnap . . . . 29-2 Server type . . . . 29-2 Web application module types . . . . 29-3 Web application module options . . . . 29-3 Application components . . . . 29-4 Web modules . . . . 29-5 Web data modules . . . . 29-5

Structure of a Web data module

unit . . . . 29-5 Interfaces implemented by a Web data

module . . . . 29-6 Web page modules . . . . 29-6 Page producer component . . . . 29-6 Page name . . . . 29-6 Producer template . . . . 29-6 Interfaces that the Web page module

implements . . . . 29-7 Web application modules . . . . 29-7

Interfaces implemented by a Web

application data module . . . . 29-7 Interfaces implemented by a Web

application page module . . . . 29-7 Adapters . . . . 29-8 Fields. . . . 29-8 Actions. . . . 29-8 Errors . . . . 29-8 Records . . . . 29-8 Page producers . . . . 29-9 Templates . . . . 29-9 Server-side scripting in WebSnap . . . . 29-9 Active scripting . . . . 29-9 Script engine . . . 29-10 Script blocks. . . 29-10 Creating script . . . 29-10 Wizard templates . . . 29-10 TAdapterPageProducer . . . 29-10 Editing and viewing script . . . 29-10 Including script in a page . . . 29-11

Script objects . . . .29-11 Dispatching requests . . . 29-12 WebContext . . . 29-13 Dispatcher components. . . 29-13 Adapter dispatcher operation . . . 29-13

Using adapter components to generate content. . . 29-13 Adapter requests and responses . . . . 29-15 Action request . . . 29-15 Action response . . . 29-15 Image request . . . 29-16 Image response. . . 29-17 Dispatching action items . . . 29-17 Page dispatcher operation . . . 29-18 WebSnap tutorial . . . 29-18 Create a new application . . . 29-19

Step 1. Start the WebSnap

application wizard . . . 29-19 Step 2. Save the generated files

and project . . . 29-19 Step 3. Specify the application title . . 29-19 Create a CountryTable page . . . 29-20 Step 1. Add a new module . . . 29-20 Step 2. Save the new module . . . 29-20 Add data components to the CountryTable

module . . . 29-20 Step 1. Add data-aware

components . . . 29-20 Step 2. Specify a key field . . . 29-21 Step 3. Add an adapter component . . 29-21 Create a grid to display the data. . . 29-22 Step 1. Add a grid . . . 29-22 Step 2. Add editing commands to

the grid . . . 29-22 Add an edit form . . . 29-23 Step 1. Add a new module . . . 29-23 Step 2. Save the new module . . . 29-23 Step 3. Use the CountryTableU

unit . . . 29-23 Step 4. Add input fields . . . 29-23 Step 5. Add buttons . . . 29-24 Step 6. Link form actions to the

grid page . . . 29-24 Step 7. Link grid actions to the

form page . . . 29-24 Add error reporting . . . 29-25

Step 1. Add error support to the

grid . . . 29-25

(20)

Step 2. Add error support to the

form . . . 29-25 Step 3. Test the error-reporting

mechanism. . . 29-26 Run the completed application . . . 29-26

Chapter 30

Working with XML documents 30-1

Using the Document Object Model . . . . 30-2 Working with XML components . . . . 30-3 Using TXMLDocument . . . . 30-3 Working with XML nodes . . . . 30-4 Working with a node’s value . . . . 30-4 Working with a node’s attributes . . . . . 30-5 Adding and deleting child nodes . . . . . 30-5 Abstracting XML documents with the

Data Binding wizard. . . . 30-5 Using the XML Data Binding wizard . . . . 30-7 Using code that the XML Data Binding

wizard generates . . . . 30-8

Chapter 31

Using Web Services 31-1

Writing Servers that support Web

Services . . . . 31-2 Building a Web Service server . . . . 31-2 Defining invokable interfaces . . . . 31-3 Using complex types in invokable

interfaces . . . . 31-5 Creating and registering the

implementation . . . . 31-6 Creating custom exception classes

for Web Services . . . . 31-7 Generating WSDL documents for a

Web Service application . . . . 31-7 Writing clients for Web Services . . . . 31-8 Importing WSDL documents . . . . 31-8 Calling invokable interfaces. . . . 31-9

Chapter 32

Working with sockets 32-1

Implementing services . . . . 32-1 Understanding service protocols . . . . 32-2 Communicating with applications . . . . 32-2 Services and ports . . . . 32-2 Types of socket connections. . . . 32-2 Client connections . . . . 32-3 Listening connections . . . . 32-3

Describing sockets . . . 32-3 Describing the host . . . 32-4

Choosing between a host name and

an IP address . . . 32-4 Using ports . . . 32-5 Using socket components . . . 32-5

Getting information about the

connection . . . 32-6 Using client sockets . . . 32-6 Specifying the desired server . . . 32-6 Forming the connection . . . 32-6 Getting information about the

connection . . . 32-6 Closing the connection . . . 32-7 Using server sockets . . . 32-7 Specifying the port. . . 32-7 Listening for client requests . . . 32-7 Connecting to clients . . . 32-7 Closing server connections . . . 32-7 Responding to socket events. . . 32-8 Error events . . . 32-8 Client events . . . 32-8 Server events. . . 32-9 Events when listening . . . 32-9 Events with client connections . . . 32-9 Reading and writing over socket

connections . . . 32-9 Non-blocking connections . . . 32-9 Reading and writing events . . . 32-10 Blocking connections . . . 32-10

Part IV

Developing COM-based applications

Chapter 33

Overview of COM technologies 33-1

COM as a specification and

implementation . . . 33-1 COM extensions . . . 33-2 Parts of a COM application . . . 33-3 COM interfaces . . . 33-3

The fundamental COM interface,

IUnknown . . . 33-4 COM interface pointers . . . 33-4 COM servers . . . 33-5 CoClasses and class factories . . . 33-6 In-process, out-of-process, and remote

servers . . . 33-6

(21)

Aggregation . . . . 33-9 COM clients . . . . 33-9 COM extensions . . . 33-10 Automation servers . . . 33-12 Active Server Pages . . . 33-12 ActiveX controls . . . 33-13 Active Documents . . . 33-13 Transactional objects . . . 33-14 Type libraries . . . 33-15 The content of type libraries . . . 33-15 Creating type libraries . . . 33-16 When to use type libraries . . . 33-16 Accessing type libraries . . . 33-16 Benefits of using type libraries . . . 33-17 Using type library tools . . . 33-18 Implementing COM objects with

wizards . . . 33-18 Code generated by wizards . . . 33-21

Chapter 34

Working with type libraries 34-1

Type Library editor . . . . 34-2 Parts of the Type Library editor. . . . 34-3 Toolbar . . . . 34-3 Object list pane . . . . 34-5 Status bar . . . . 34-5 Pages of type information . . . . 34-6 Type library elements . . . . 34-8 Interfaces. . . . 34-8 Dispinterfaces . . . . 34-9 CoClasses . . . . 34-9 Type definitions . . . 34-10 Modules . . . 34-10 Using the Type Library editor. . . 34-11 Valid types . . . 34-11 Using Object Pascal or IDL syntax . . . 34-13 Creating a new type library . . . 34-19 Opening an existing type library . . . . 34-19 Adding an interface to the type

library . . . 34-20 Modifying an interface using the

type library . . . 34-20 Adding properties and methods to an

interface or dispinterface . . . 34-21 Adding a CoClass to the type

library . . . 34-22 Adding an interface to a CoClass . . . . 34-23

Adding an enumeration to the type

library . . . 34-23 Adding an alias to the type library . . 34-23 Adding a record or union to the type

library . . . 34-24 Adding a module to the type

library . . . 34-24 Saving and registering type library

information . . . 34-24 Apply Updates dialog. . . 34-25 Saving a type library . . . 34-25 Refreshing the type library . . . 34-26 Registering the type library. . . 34-26 Exporting an IDL file . . . 34-26 Deploying type libraries . . . 34-27

Chapter 35

Creating COM clients 35-1

Importing type library information . . . 35-2 Using the Import Type Library dialog . . . 35-3 Using the Import ActiveX dialog . . . 35-4 Code generated when you import type

library information . . . 35-5 Controlling an imported object . . . 35-6 Using component wrappers . . . 35-6 ActiveX wrappers . . . 35-6 Automation object wrappers . . . 35-7 Using data-aware ActiveX controls . . . 35-8 Example: Printing a document with

Microsoft Word . . . 35-9 Step 1: Prepare Delphi for this

example . . . 35-9 Step 2: Import the Word type

library . . . 35-10 Step 3: Use a VTable or dispatch interface

object to control Microsoft Word . . . 35-10 Step 4: Clean up the example . . . .35-11 Writing client code based on type library

definitions . . . 35-12 Connecting to a server . . . 35-12 Controlling an Automation server

using a dual interface . . . 35-12 Controlling an Automation server

using a dispatch interface . . . 35-13 Handling events in an automation

controller . . . 35-13 Creating Clients for servers that do not

have a type library . . . 35-15

(22)

Chapter 36

Creating simple COM servers 36-1

Overview of creating a COM object . . . . 36-2 Designing a COM object . . . . 36-2 Using the COM object wizard . . . . 36-2 Using the Automation object wizard . . . . 36-4 COM object instancing types . . . . 36-5 Choosing a threading model . . . . 36-6

Writing an object that supports the free threading model. . . . 36-7 Writing an object that supports the

apartment threading model . . . . 36-8 Writing an object that supports the

neutral threading model . . . . 36-9 Defining a COM object’s interface . . . . 36-9

Adding a property to the object’s

interface . . . . 36-9 Adding a method to the object’s

interface . . . 36-10 Exposing events to clients . . . 36-10

Managing events in your

Automation object . . . 36-12 Automation interfaces . . . 36-12 Dual interfaces . . . 36-13 Dispatch interfaces . . . 36-14 Custom interfaces . . . 36-14 Marshaling data . . . 36-15 Automation compatible types . . . 36-15 Type restrictions for automatic

marshaling . . . 36-16 Custom marshaling . . . 36-16 Registering a COM object . . . 36-16 Registering an in-process server . . . 36-17 Registering an out-of-process server . . . . 36-17 Testing and debugging the application . . . . 36-17

Chapter 37

Creating an Active Server Page 37-1

Creating an Active Server Object. . . . 37-2 Using the ASP intrinsics . . . . 37-3 Application . . . . 37-4 Request. . . . 37-4 Response . . . . 37-5 Session . . . . 37-5 Server . . . . 37-6 Creating ASPs for in-process or

out-of-process servers . . . . 37-7 Registering an Active Server Object . . . . 37-7

Registering an out-of-process server . . . . 37-8 Testing and debugging the Active Server

Page application. . . 37-8

Chapter 38

Creating an ActiveX control 38-1

Overview of ActiveX control creation . . . 38-2 Elements of an ActiveX control . . . 38-2 VCL control. . . 38-3 ActiveX wrapper. . . 38-3 Type library. . . 38-3 Property page . . . 38-3 Designing an ActiveX control . . . 38-4 Generating an ActiveX control from a

VCL control . . . 38-4 Generating an ActiveX control based on

a VCL form. . . 38-5 Licensing ActiveX controls. . . 38-6 Customizing the ActiveX control’s

interface . . . 38-7 Adding additional properties, methods,

and events . . . 38-8 Adding properties and methods . . . 38-8 Adding events . . . 38-9 Enabling simple data binding with the

type library . . . 38-10 Creating a property page for an ActiveX

control . . . .38-11 Creating a new property page . . . 38-12 Adding controls to a property page . . . . 38-12 Associating property page controls with

ActiveX control properties . . . 38-13 Updating the property page . . . 38-13 Updating the object . . . 38-13 Connecting a property page to an ActiveX

control. . . 38-14 Registering an ActiveX control . . . 38-14 Testing an ActiveX control . . . 38-14 Deploying an ActiveX control on the

Web . . . 38-15 Setting options . . . 38-16

Chapter 39

Creating MTS or COM+ objects 39-1

Understanding transactional objects . . . 39-2 Requirements for a transactional

object . . . 39-3 Managing resources . . . 39-3 Accessing the object context . . . 39-4

Références

Documents relatifs

When in november 2011 i was asked to be guest editor of the bulletin of tibetology, this was an opportunity for me to continue a work i had happily accepted in the past for

When in november 2011 i was asked to be guest editor of the bulletin of tibetology, this was an opportunity for me to continue a work i had happily accepted in the past for

A partir de simulations de la zone convective solaire (dans laquelle les contours d’isorotation ne sont pas alignés avec l’axe de rotation mais de direction radiale) (e.g. Miesch et

Le taureau entravé des pattes de derrière Mithra va le porter pour son heure dernière Un corbeau dans la grotte envoyé du soleil Assiste au sacrifice lui donnant des conseils

[r]

Le secteur « privé et semi-public » (17 millions de salariés au 31 décembre 2016) et le champ de la présente étude (conventions collectives de branche non agricoles, soit

repères spectraux ayant pour but de nous diriger autre part, ne sont que l’intimation du fait que Proust pense qu’il a une vérité à lui à exprimer sur la

Coupez et coller le prochain object qui devrait apparaitre dans la suite1. `