+ All Categories
Home > Documents > CBuilderGuide

CBuilderGuide

Date post: 29-Nov-2014
Category:
Upload: plcmana
View: 347 times
Download: 3 times
Share this document with a friend
1284
Developer’s Guide Borland Software Corporation 100 Enterprise Way, Scotts Valley, CA 95066-3249 Borland ® C ++ Builder 6 for Windows ®
Transcript

Developers Guide

Borland

C++Builder 6

for Windows

Borland Software Corporation 100 Enterprise Way, Scotts Valley, CA 95066-3249

Refer to the DEPLOY document located in the root directory of your C++Builder product for a complete list of files that you can distribute in accordance with the C++Builder 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. CPE1360WW21001 6E4R0102 02030405-9 8 7 6 5 4 3 2 1 PDF

ContentsChapter 1

IntroductionWhats in this manual? . . . . . . . . Manual conventions . . . . . . . . . . Developer support services . . . . Ordering printed documentation. . . . . . . . . . . . . . . . . . . . . . . . .

1-11-1 1-3 1-3 1-3

Part I

Programming with C++BuilderChapter 2

Developing applications with C++BuilderIntegrated development environment . Designing applications . . . . . . . . . Creating projects . . . . . . . . . . . . . Editing code . . . . . . . . . . . . . . . Compiling applications . . . . . . . . . Debugging applications . . . . . . . . . Deploying applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-12-1 2-2 2-3 2-3 2-4 2-4 2-5

Chapter 3

Using the class librariesUnderstanding the class libraries . . . . . Properties, methods, and events . . . . Properties . . . . . . . . . . . . . . . Methods . . . . . . . . . . . . . . . . Events . . . . . . . . . . . . . . . . . User events . . . . . . . . . . . . . . System events . . . . . . . . . . . . . Objects, components, and controls . . . . . TObject branch . . . . . . . . . . . . . . TPersistent branch . . . . . . . . . . . . TComponent branch . . . . . . . . . . . TControl branch . . . . . . . . . . . . . TWinControl/TWidgetControl branch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-13-1 3-2 3-2 3-3 3-3 3-3 3-3 3-4 3-5 3-6 3-7 3-8 3-9

Chapter 4

Using BaseCLXUsing streams . . . . . . . . . . . . . . . . . . Using streams to read or write data . . . . Stream methods for reading and writing . . . . . . . . . . . . . . . . . . Reading and writing components. . . . Copying data from one stream to another .

4-1. 4-2 . 4-2 . 4-2 . 4-3 . 4-3 i

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 . . . . . . . . . . . . . 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 routines for AnsiStrings . . . . . . . . . . . . . . . .

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

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

. 4-3 . 4-4 . 4-4 . 4-4 . 4-5 . 4-5 . 4-6 . 4-6 . 4-7 . 4-7 . 4-7 . 4-9 . 4-9 . 4-9 4-10 4-10 4-11 4-12 4-12 4-13 4-13 4-14 4-14 4-14 4-14 4-15 4-15 4-16 4-16 4-16 4-17 4-18 4-18 4-18 4-18 4-18 4-18 4-19

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

Commonly used routines for null-terminated strings. . . . . . . . . Printing . . . . . . . . . . . . . . . . . . . . Converting measurements . . . . . . . . . Performing conversions . . . . . . . . . Performing simple conversions . . . Performing complex conversions . . Adding new measurement types . . . . 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 . . . . . . . . . . . Creating drawing spaces . . . . . . . . . .

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

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

. 4-23 . 4-25 . 4-25 . 4-26 . 4-26 . 4-26 . 4-26 . 4-27 . 4-27 . 4-27 . 4-27 . 4-28 . 4-28 . 4-28 . 4-28 . 4-29 . 4-29 . 4-29 . 4-29 . 4-30 . 4-30 . 4-31

Associating menu events with event handlers. . . . . . . . . . . . . . . . Deleting event handlers . . . . . . . Cross-platform and non-cross-platform components . . . . . . . . . . . . . . . Adding custom components to the Component palette . . . . . . . . .

. . . . . 5-5 . . . . . 5-6 . . . . . 5-6 . . . . . 5-8

Chapter 6

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 . . . . . . Adding graphics to controls . . . . . . . . . Indicating that a control is ownerdrawn . . . . . . . . . . . . . . . . . . . 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 . . . . . . . . . . . . . . . . .

6-1. 6-1 . 6-1 . 6-2 . 6-2 . 6-3

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

. . . 4-31 . . . 4-32 . . . 4-33

Chapter 5

Working with componentsSetting component properties . . . . . . . . Setting properties at design time . . . . . Using property editors . . . . . . . . . Setting properties at runtime . . . . . . . Calling methods . . . . . . . . . . . . . . . . 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. . . . . . . . . . . . . . . . . . . . . . . . . . . .

5-15-2 5-2 5-2 5-3 5-3

. . 5-3 . . 5-4 . . 5-4 . . 5-4 . . 5-4 . . 5-5 . . 5-5

. . 6-11 . . . . . . . . . . . . 6-12 6-12 6-12 6-13 6-14 6-14

ii

Chapter 7

Building applications, components, and libraries 7-1Creating applications . . . . . . . . . . . . . GUI applications . . . . . . . . . . . . . . User interface models . . . . . . . . . SDI applications. . . . . . . . . . . . . MDI applications . . . . . . . . . . . . Setting IDE, project, and compilation options . . . . . . . . . . . . . . . . . Programming templates . . . . . . . . . . Console applications . . . . . . . . . . . . Using the VCL and CLX in console applications . . . . . . . . . . . . . . Service applications . . . . . . . . . . . . Service threads . . . . . . . . . . . . . Service name properties . . . . . . . . Debugging service applications . . . . Creating packages and DLLs . . . . . . . . . When to use packages and DLLs . . . . . Using DLLs in C++Builder . . . . . . . . . . Creating DLLs in C++Builder . . . . . . . . Creating DLLs containing VCL and CLX components . . . . . . . . . . . . . . . . . . Linking DLLs . . . . . . . . . . . . . . . . . . Writing database applications . . . . . . . . Distributing database applications . . . . Creating Web server applications . . . . . . Using Web Broker . . . . . . . . . . . . . Creating WebSnap applications. . . . . . Using InternetExpress . . . . . . . . . . . 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 . . . . . . . . . . . . . . . . . Accessing a data module from a form . . Adding a remote data module to an application server project . . . . . . . . Using the Object Repository . . . . . . . . . . . . . . . . . . . 7-1 7-1 7-2 7-2 7-2

. . 7-3 . . 7-3 . . 7-4 . . . . . . . . . . . . . . . . . . . . . . . 7-4 . 7-4 . 7-7 . 7-8 . 7-9 . 7-10 . 7-11 . 7-11 . 7-11 . 7-12 . 7-15 . 7-15 . 7-16 . 7-16 . 7-17 . 7-18 . 7-18 . 7-18 . 7-19 . 7-19 . 7-19 . 7-20

. . 7-20 . . 7-21 . . 7-22 . . 7-22 . . 7-23 . . 7-23 . . 7-23 . . 7-24

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 IExtendedHelp Viewer . . . . . . . . . . . . . . . . . . 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 . . . . .

. . 7-24 . . 7-24 . . 7-24 . . . . . . . . . . . . . . . . . . . . 7-25 7-25 7-25 7-25 7-25 7-26 7-26 7-26 7-27 7-28

. . 7-28 . . 7-28 . . 7-29 . . 7-30 . . . . . . . . . . . . 7-30 7-31 7-32 7-32 7-32 7-33

. . 7-33 . . 7-33 . . 7-34 . . . . . . . . . . 7-34 7-34 7-35 7-35 7-35

Chapter 8

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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

8-1. 8-1 . 8-2 . 8-2 . 8-2 . 8-2 . 8-3

iii

Adding forms . . . . . . . . . . . . . . . . Linking forms . . . . . . . . . . . . . . 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 . . . . . . . . . . Creating toolbars and menus . . . . . . . Adding color, patterns, or pictures to menus, buttons, and toolbars . . . Adding icons to menus and toolbars. . . . . . . . . . . . . . . . . Creating toolbars and menus that users can customize. . . . . . . . . . Hiding unused items and categories in action bands . . . . . . . . . . . . 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 . . . . . . . .

. . . .

. . . .

8-3 8-3 8-4 8-5

. . 8-5 . . 8-5 . . 8-6 . . 8-6 . . 8-7 . . 8-7 . . 8-8 . . 8-8 . . 8-10 . . . . . . . . . . . . . . 8-12 . 8-12 . 8-13 . 8-13 . 8-14 . 8-14 . 8-15 . 8-15 . 8-16 . 8-16 . 8-18 . 8-18 . 8-19

. . 8-20 . . 8-21 . . 8-22 . . . . . . . . . . 8-22 . 8-23 . 8-23 . 8-24 . 8-24 . 8-26 . 8-26 . 8-27 . 8-28

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 . . . 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 . . .

. . . . . .

8-28 8-29 8-30 8-30 8-31 8-31

. 8-31 . 8-33 . 8-33 . 8-34 . . . . 8-34 8-35 8-35 8-36

. 8-36 . 8-37 . 8-37 . 8-37 . 8-38 . 8-39 . 8-40 . 8-40 . 8-41 . 8-41 . 8-41 . 8-42 . 8-42 . 8-43 . 8-44 . 8-44 . 8-44 . 8-45 . 8-45 . 8-45 . 8-46 . 8-46

iv

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 . . . . . .

. . . . . . . . .

. . . . . . . . .

. 8-46 . 8-47 . 8-47 . 8-47 . 8-48 . 8-48 . 8-48 . 8-49 . 8-49

Chapter 9

Types of controlsText controls . . . . . . . . . . . . . . Edit controls. . . . . . . . . . . . . Edit control properties . . . . . . . Memo and rich edit controls. . Text viewing controls (CLX only). Labels . . . . . . . . . . . . . . . . Specialized input controls. . . . . . . Scroll bars . . . . . . . . . . . . . . Track bars . . . . . . . . . . . . . . Up-down controls (VCL only) . . Spin edit controls (CLX only) . . . Hot key controls (VCL only) . . . Splitter controls . . . . . . . . . . . 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 . . . . . . . . . . . . . . Date-time pickers and month calendars (VCL only). . . . . . . Grouping controls . . . . . . . . . . . Group boxes and radio groups . . Panels . . . . . . . . . . . . . . . . Scroll boxes . . . . . . . . . . . . . Tab controls . . . . . . . . . . . . . Page controls . . . . . . . . . . . . Header controls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

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

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 (VCL only) .

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

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

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

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

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

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

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

9-14 9-14 9-14 9-15 9-15 9-15 9-15 9-16 9-16 9-17 9-17 9-17 9-17 9-17

Chapter 10

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 . . . . . . . . . Using the clipboard with graphics . . . Copying graphics to the clipboard . . . . . . . . . . . . . . .

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

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

. 10-22

v

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) . . . . . .

. . . 10-22 . . . 10-22 . . . 10-23 . . . 10-24 . . . 10-25 . . . 10-26 . . . 10-27 . . . 10-29 . . . 10-29 . . . 10-30 . . . 10-31 . . . 10-33

Starting and stopping threads . . . . . . . .11-11 Debugging multi-threaded applications . . . .11-12 Naming a thread. . . . . . . . . . . . . . . .11-12 Converting an unnamed thread to a named thread . . . . . . . . . . . . . . . . . . .11-12 Assigning separate names to similar threads . . . . . . . . . . . . . . . . . .11-13

Chapter 12

Exception handlingC++ exception handling . . . . . . . . . . . Exception handling syntax . . . . . . . . The try block . . . . . . . . . . . . . . The throw statement. . . . . . . . . . The catch statement . . . . . . . . . . Rethrowing exceptions . . . . . . . . . . Exception specifications . . . . . . . . . Unwinding exceptions . . . . . . . . . . Safe pointers . . . . . . . . . . . . . . Constructors in exception handling . . . Handling uncaught and unexpected exceptions . . . . . . . . . . . . . . . . Structured exceptions under Win32. . . . . Syntax of structured exceptions . . . . . Handling structured exceptions . . . . . Exception filters . . . . . . . . . . . . . . Mixing C++ with structured exceptions . . . . . . . . . . . . . . . . C-based exceptions in C++ program example . . . . . . . . . . . . . . . . Defining exceptions . . . . . . . . . . . . Raising exceptions. . . . . . . . . . . . . Termination blocks . . . . . . . . . . . . C++Builder exception handling options . . . . . . . . . . . . . . . . . . VCL/CLX exception handling . . . . . . . Differences between C++ and VCL/CLX exception handling . . . . . Handling operating system exceptions . Handling VCL and CLX exceptions . . . VCL and CLX exception classes . . . . . Portability considerations . . . . . . . . . . . . . . . . . . . . . . .

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

Chapter 11

Writing multi-threaded applications 11-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 . . . . . . . . . . . . . . . Executing thread objects . . . . . . . . . . . Overriding the default priority . . . . . . . . . . . . . . 11-1 . 11-2 . 11-2 . 11-3 . 11-4 . 11-4 . 11-5

. 12-10 . . . . .12-11 12-12 12-12 12-13

. . 11-6 . . . . . . . 11-6 . 11-7 . 11-7 . 11-7 . 11-7 . 11-8

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

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

Chapter 13

C++ language support for the VCL and CLX

13-1

C++ and Object Pascal object models. . . . . . 13-1 Inheritance and interfaces . . . . . . . . . . 13-2

vi

Using interfaces instead of multiple inheritance . . . . . . . . . . . . . . Declaring interface classes . . . . . . IUnknown and IInterface . . . . . . Creating classes that support IUnknown . . . . . . . . . . . . . . Interfaced classes and lifetime management . . . . . . . . . . . . . Object identity and instantiation . . . . Distinguishing C++ and Object Pascal references . . . . . . . . . . Copying objects . . . . . . . . . . . . Objects as function arguments . . . Object construction for C++Builder VCL/CLX classes . . . . . . . . . . . . C++ object construction . . . . . . . Object Pascal object construction . . C++Builder object construction . . . Calling virtual methods in base class constructors . . . . . . . . . . . . . . . Object Pascal model . . . . . . . . . C++ model. . . . . . . . . . . . . . . C++Builder model . . . . . . . . . . Example: calling virtual methods . . Constructor initialization of data members for virtual functions. . . . Object destruction . . . . . . . . . . . . Exceptions thrown from constructors . . . . . . . . . . . . . Virtual methods called from destructors . . . . . . . . . . . . . . AfterConstruction and Before Destruction . . . . . . . . . . . . . . . Class virtual functions . . . . . . . . . . Support for Object Pascal data types and language concepts . . . . . . . . . . Typedefs . . . . . . . . . . . . . . . . . . Classes that support the Object Pascal language . . . . . . . . . . . . . C++ language counterparts to the Object Pascal language. . . . . . . . . Var parameters . . . . . . . . . . . . Untyped parameters . . . . . . . . . Open arrays . . . . . . . . . . . . . . . . Calculating the number of elements . . . . . . . . . . . . . . . Temporaries . . . . . . . . . . . . . . array of const . . . . . . . . . . . . . OPENARRAY macro . . . . . . . . .

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

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

EXISTINGARRAY macro . . . . . . C++ functions that take open array arguments. . . . . . . . . . . . . . Types defined differently . . . . . . . . Boolean data types. . . . . . . . . . Char data types . . . . . . . . . . . Delphi interfaces. . . . . . . . . . . . . Resource strings . . . . . . . . . . . . . Default parameters . . . . . . . . . . . Runtime type information . . . . . . . Unmapped types . . . . . . . . . . . . 6-byte Real types . . . . . . . . . . . Arrays as return types of functions . . . . . . . . . . . . . . Keyword extensions. . . . . . . . . . . __classid . . . . . . . . . . . . . . . __closure . . . . . . . . . . . . . . . __property . . . . . . . . . . . . . . __published. . . . . . . . . . . . . . The __declspec keyword extension . . __declspec(delphiclass) . . . . . . . __declspec(delphireturn) . . . . . . __declspec(delphirtti) . . . . . . . . __declspec(dynamic) . . . . . . . . __declspec(hidesbase) . . . . . . . . __declspec(package) . . . . . . . . . __declspec(pascalimplementation) __declspec(uuid) . . . . . . . . . . .

. . 13-19 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-19 13-19 13-19 13-20 13-20 13-21 13-21 13-22 13-23 13-23 13-23 13-23 13-23 13-24 13-26 13-27 13-28 13-28 13-28 13-28 13-29 13-29 13-29 13-29 13-29

Chapter 14

Developing cross-platform applicationsCreating cross-platform applications . . Porting Windows applications to Linux Porting techniques . . . . . . . . . . Platform-specific ports . . . . . . Cross-platform ports . . . . . . . Windows emulation ports . . . . Porting your application . . . . . . . CLX versus VCL . . . . . . . . . . . . What CLX does differently . . . . . . Look and feel . . . . . . . . . . . . Styles . . . . . . . . . . . . . . . . Variants . . . . . . . . . . . . . . . Registry . . . . . . . . . . . . . . . Other differences. . . . . . . . . . Missing in CLX . . . . . . . . . . . . Features that will not port directly . CLX and VCL unit comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

14-1. . . . . . . . . . . . . . . . . 14-1 14-2 14-2 14-2 14-3 14-3 14-3 14-5 14-5 14-6 14-6 14-6 14-6 14-7 14-7 14-8 14-8

vii

Differences in CLX object constructors . . . . . . . . . . . . . Handling system and widget events . . . . . . . . . . . . . . . . Sharing source files between Windows and Linux . . . . . . . . Environmental differences between Windows and Linux . . . . . . . . Directory structure on Linux . . . . Writing portable code . . . . . . . . Using conditional directives . . . Emitting messages . . . . . . . . Including inline assembler code. Programming differences 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 . . . . . . . . . . . . . . . . .

. . . . 14-11 . . . . 14-12 . . . . 14-12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-13 14-15 14-15 14-16 14-17 14-18 14-19 14-19 14-20 14-21 14-21

Contains list . . . . . . . . . . . . . Building packages . . . . . . . . . . . . Package-specific compiler directives . . . . . . . . . . . . . . Using the command-line compiler and linker . . . . . . . . . . . . . . Package files created by building . Deploying packages . . . . . . . . . . . . Deploying applications that use packages . . . . . . . . . . . . . . . . Distributing packages to other developers . . . . . . . . . . . . . . . Package collection files . . . . . . . . .

. . 15-10 . . 15-10 . . .15-11 . . 15-12 . . 15-12 . . 15-13 . . 15-13 . . 15-13 . . 15-13

Chapter 16

Creating international applicationsInternationalization 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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

16-1. . . . . . . . . 16-1 16-1 16-1 16-2 16-2 16-2 16-2 16-3 16-3

. . . . 14-22 . . . . 14-24 . . . . 14-25 . . . . 14-26

Chapter 15

Working with packages and componentsWhy use packages? . . . . . . . . . . . Packages and standard DLLs . . . . Runtime packages . . . . . . . . . . . . Using packages in an application. . Dynamically loading packages . . . 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 . . . . . Package source files and project options files . . . . . . . . . . . . . Packaging components. . . . . . Understanding the structure of a package . . . . . . . . . . . . . . Naming packages . . . . . . . . . Requires list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

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

. 16-4 . 16-6 . 16-8 . 16-8 . 16-8 . 16-9 . 16-9 . 16-9 16-10 16-10 .16-11

. 16-12 . 16-12 . 16-12

. . . . . 15-8 . . . . . 15-8 . . . . . 15-9 . . . . . 15-9 . . . . . 15-9

Chapter 17

Deploying applicationsDeploying general applications . . Using installation programs . . Identifying application files Application files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

17-1. . . . 17-1 17-2 17-2 17-3

viii

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 . . . . . SQL Links . . . . . . . . . . . . . . Deploying multi-tiered database applications (DataSnap) . . . . . . . Deploying Web applications . . . . . . . Deploying to Apache servers . . . . . 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 .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. 17-3 . 17-3 . 17-5 . 17-5 . 17-5 . 17-6 . 17-6 . 17-7 . 17-8 . 17-8 . 17-9

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. . . . . . . . . . . . . . . .

. 18-7 . 18-9 18-10 .18-11 18-12 18-14 18-15 18-15 18-16

Chapter 19

. . . 17-10 . . . 17-10 . . . 17-10 . . . 17-11 . . . 17-12 . . . 17-12 . . . 17-12 . . . . . . . . . . . . . . . . . . . . . . . . 17-13 17-14 17-14 17-15 17-15 17-15 17-15 17-15

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 . . . . . . 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 . . . . . . .

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

Part II

Developing database applicationsChapter 18

. . 19-8 . . 19-8 . . 19-9 . . 19-9 . 19-10 . 19-13 . 19-13 . 19-14

Designing database applicationsUsing databases . . . . . . . . . . . . . . . . Types of databases . . . . . . . . . . . . . Database security. . . . . . . . . . . . . . Transactions . . . . . . . . . . . . . . . . . Referential integrity, stored procedures, and triggers . . . . . . . . . . . . . . . . Database architecture . . . . . . . . . . . . . General structure . . . . . . . . . . . . . . The user interface form. . . . . . . . . The data module . . . . . . . . . . . . . . . . . . . . .

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

ix

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 . . . . . . . . . . . . . . . .

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

. . . 19-26 . . . 19-27 . . . 19-28 . . . 19-29 . . . 19-29 . . . 19-29 . . . 19-30 . . . 19-30

Chapter 20

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 . . . . . . . . . . . . . . . . . . . . . . . . . .

20-1. 20-1 . 20-2 . 20-2 . 20-3

. . . . . 20-3 . . . . . 20-4 . . . . . 20-5

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 . . . . . . . . . . . . . . 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 . . . . . . . .

. . . .

. . . .

. . . .

20-6 20-7 20-7 20-7

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

. . .20-11 . . .20-11 . . .20-11 . . . . . . . . . . . . . . 20-12 20-12 20-13 20-13 20-13 20-15 20-15

. . 20-16 . . 20-17 . . . . . . . . 20-18 20-18 20-18 20-19

. . 20-19 . . 20-19 . . 20-20 . . 20-20

x

Chapter 21

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 . . . . . . . . . . . . . . . . Obtaining metadata . . . . . . . . . . . . Listing available tables. . . . . . . . . Listing the fields in a table . . . . . . Listing available stored procedures . Listing available indexes . . . . . . . Listing stored procedure parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . .

21-1. 21-2 . 21-2 . 21-3 . 21-3 . 21-4 . 21-6 . 21-6 . 21-8 . 21-8

. . . . 21-8 . . . . 21-9 . . . 21-10 . . . 21-12 . . . 21-12 . . . . . . . . . . . . . . . . . . . . . 21-12 21-13 21-13 21-13 21-14 21-14 21-14

Chapter 22

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 Bookmark Valid methods . . . . . . . . . . . . The CompareBookmarks method . . The FreeBookmark method . . . . . A bookmarking example. . . . . . . Searching datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

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

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 . . . . . . . . . . . . . . . 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 . . . . . . . . . .

. . 22-10 . . .22-11 . . . . . . . . 22-12 22-13 22-13 22-14

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

. . 22-25 . . 22-26 . . 22-26 . . 22-26 . . 22-27 . . 22-27 . . 22-28 . . 22-29 . . . . . . . . 22-29 22-29 22-29 22-30

. . 22-30 . . 22-30

xi

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 . . . . . . . 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 . . . . . . .

. 22-33 . 22-34 . 22-34 . 22-34 . 22-36 . . . . . . . . 22-37 22-37 22-37 22-40 22-40 22-40 22-41 22-42

. 22-42 . 22-43 . 22-43 . 22-44 . 22-45 . 22-46 . 22-47 . 22-47 . 22-48 . 22-48 . 22-50 . 22-50 . 22-52 . 22-52 . 22-53 . 22-53

Chapter 23

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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

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

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 . . . . . . . . . . . . . . . . . . . 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 . . . . . . . . . . . . . . . . .

. 23-7 . 23-8 23-10 23-10 23-10 .23-11 23-12 23-12 23-13 23-14 23-14 23-14 23-15 23-16 23-17 23-17 23-17 23-19 23-19 23-20 23-20 23-21 23-21 23-21 23-22 23-23 23-23 23-24 23-24 23-24 23-24

xii

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 . . . . . . . . . . . . . . . . .

. . . 23-24 . . . 23-25 . . . 23-25 . . . 23-25 . . . 23-25 . . . 23-25 . . . 23-26 . . . 23-26 . . . 23-26 . . . 23-26 . . . 23-27

Chapter 24

Using the Borland Database EngineBDE-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 . . . . . . . .

24-1. . 24-1 . . 24-2 . . . . . 24-3 . 24-4 . 24-4 . 24-4

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

. 24-12 . 24-12 . 24-12 . 24-13 . 24-13

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 . . . . . . . . . . . . . . . . . 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 . . . . . . . . . . . .

. 24-15 . 24-16 . 24-16 . 24-17 . 24-18 . 24-19 . 24-21 . 24-23 . 24-24 . . . . . . . . 24-26 24-26 24-27 24-28 24-29 24-30 24-31 24-31

. 24-33 . 24-33 . 24-34 . 24-35 . 24-35 . 24-37 . 24-39 . . . . . . . . 24-40 24-43 24-44 24-47 24-47 24-48 24-48 24-49

. 24-49 . 24-49 . 24-49

xiii

Mapping data types . . . . . Executing a batch move . . . Handling batch move errors The Data Dictionary . . . . . . . Tools for working with the BDE

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

24-49 24-50 24-51 24-51 24-53

Chapter 26

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 . . . . . . . . . . . . . . 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 . . . . . . . . . . . . . . . . . . . . . . .

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

Chapter 25

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. . . . . . . . . . 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 . . . . .

25-1. . 25-1 . . 25-2 . . . . . . 25-3 . 25-4 . 25-4 . 25-5 . 25-5

. . 26-6 . . 26-7 . . . . . . . . 26-7 26-8 26-8 26-9

. . 25-5 . . 25-6 . . 25-7 . . 25-7 . . 25-7 . . 25-7 . . 25-8 . . 25-8 . . 25-8 . . 25-9 . 25-10 . 25-10 . 25-11 . 25-11 . . . . . . 25-14 25-15 25-16 25-17 25-17 25-17

. . 26-9 . . 26-9 . 26-10 . 26-10 . .26-11 . 26-12 . 26-12 . 26-13 . 26-13 . 26-17 . 26-17 . 26-18

Chapter 27

. 25-18 . 25-18

Using client datasets

27-1

Working with data using a client dataset . . . . . . . . . . . . . . . . . . . . . . 27-2 Navigating data in client datasets . . . . . . 27-2

xiv

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 . . . . . . 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 . . . . . . . . . . . . .

. . . . . . . . . . .

. 27-2 . 27-5 . 27-5 . 27-6 . 27-6 . 27-7 . 27-7 . 27-8 . 27-9 . 27-9 27-10

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 . . . . .

. . 27-30 . . 27-31 . . . . . . . . . . 27-32 27-32 27-33 27-33 27-34

Chapter 28

Using provider components. 27-10 . 27-11 . 27-11 . . . . . 27-12 27-13 27-13 27-14 27-14 Determining 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 . . . . . . . .

28-1. . . 28-2 . . . 28-2 . . . 28-2 . . . 28-3 . . . 28-4 . . . 28-4 . . . 28-4 . . . 28-5 . . . 28-6 . . . 28-7 . . . 28-8 . . . 28-9 . . . 28-9 . . .28-11 . . .28-11 . . .28-11 . . 28-12 . . 28-12

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

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

Chapter 29

Creating multi-tiered applications

29-1

Advantages of the multi-tiered database model . . . . . . . . . . . . . . . . . . . . . . . 29-2 Understanding provider-based multitiered applications . . . . . . . . . . . . . . . 29-2

xv

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. . . . . . . . Building a multi-tiered application . . . . . Creating the application server. . . . . . . . Setting up the remote data module. . . . Configuring the remote data module when it is not transactional . . . . . Configuring a transactional remote data module . . . . . . . . . . . . . . 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 . . . . . . . . . . . . . . . . . .

. . 29-3 . . 29-4 . . 29-5 . . 29-6 . . . . . . . . . . . 29-6 . 29-8 . 29-9 . 29-9 . 29-9 29-10 29-11 29-11 29-12 29-13

. 29-13 . 29-14 . 29-15 . 29-16 . 29-17 . 29-17 . 29-17 . 29-18 . 29-19 . 29-20 . 29-21 . 29-21 . 29-22 . 29-23 . 29-23 . 29-24

Specifying a connection using SOAP . . . . . . . . . . . . . . . . Brokering connections . . . . . . . Managing server connections . . . . . Connecting to the server . . . . . . Dropping or changing a server onnection . . . . . . . . . . . . . . Calling server interfaces . . . . . . . . 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 . . . . . . . . . . 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 . . . . . .

. . . .

. . . .

29-25 29-25 29-26 29-26

. . 29-26 . . 29-27 . . 29-28 . . 29-28 . . 29-30 . . 29-30 . . 29-31 . . 29-31 . . 29-33 . . 29-33 . . 29-34 . . 29-34 . . 29-35 . . 29-36 . . 29-37 . . 29-37 . . 29-38

Chapter 30

Using XML in database applications 30-1Defining 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 . . . . . 30-1 . . . . 30-2 . . . . 30-4 . . . . 30-4 . . . . 30-4 . . . . 30-5 . . . . 30-6 . . . . 30-6 . . . . 30-7 . . . . 30-7

xvi

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 . . . . . . .

. . . . 30-7 . . . . 30-8 . . . . 30-9 . . . . 30-9 . . . 30-10

Part III

Writing Internet applicationsChapter 31

Writing CORBA applicationsOverview of a CORBA application . . . . Understanding stubs and skeletons . . Using Smart Agent . . . . . . . . . . . . Activating server applications . . . . . Binding interface calls dynamically . . Writing CORBA servers . . . . . . . . . . . Defining object interfaces . . . . . . . . Using the CORBA Server Wizard. . . . Generating stubs and skeletons from an IDL file . . . . . . . . . . . . . . . . Using the CORBA Object Implementation Wizard . . . . . . . . . . . . . . . Instantiating CORBA objects . . . . Using the delegation model . . . . . Viewing and editing changes . . . . Implementing CORBA Objects . . . . . Guarding against thread conflicts . . . . . . . . . . . . . . . Changing CORBA interfaces . . . . . . Registering server interfaces . . . . . . Writing CORBA clients . . . . . . . . . . . Using stubs . . . . . . . . . . . . . . . . Using the dynamic invocation interface . . . . . . . . . . . . . . . . . Testing CORBA servers . . . . . . . . . . . Setting up the testing tool . . . . . . . . Recording and running test scripts . . . . . . . . . . . . . . . . . . .

31-1. 31-1 . 31-2 . 31-3 . 31-3 . 31-4 . 31-4 . 31-5 . 31-5

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

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 . . . . . . . . . . Win-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. . . . . . . . . . . . .

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

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

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

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

32-3 32-4 32-4 32-5 32-5 32-5 32-6 32-6 32-6 32-7 32-7 32-7 32-7

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

. . . 32-10 . . . 32-10 . . . .32-11

Chapter 33

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 . . . . 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 . . . . . . .

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

Chapter 32

Creating Internet server applications

32-1

. . . . 33-6 . . . . 33-7 . . . . 33-7 . . . . 33-8

About Web Broker and WebSnap . . . . . . . . 32-1 Terminology and standards. . . . . . . . . . . . 32-3

xvii

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. . . . . . . . . . . . . . . . . . . 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 . . . . . . . . . . . . . . .

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

Setting up a dataset table producer . . . . . . . . . . . . . . . . 33-20 Setting up a query table producer . . . . . . . . . . . . . . . . 33-20

Chapter 34

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 . . . . . . . . . . . . . . . . . . . WebSnap tutorial . . . . . . . . . . . . . . . . Create a new application . . . . . . . . . . Step 1. Start the WebSnap application wizard . . . . . . . . . . . . . . . . . . Step 2. Save the generated files and project . . . . . . . . . . . . . . . . . . Step 3. Specify the application title. . . . . . . . . . . . . . . . . . . . Create a CountryTable page . . . . . . . . Step 1. Add a new Web page module . . . . . . . . . . . . . . . . . Step 2. Save the new Web page module . . . . . . . . . . . . . . . . . Add data components to the CountryTable module . . . . . . . . . . . . . . . . Step 1. Add data-aware components . . . . . . . . . . . . . . . Step 2. Specify a key field . . . . . . . . Step 3. Add an adapter component . . . . . . . . . . . . . . . Create a grid to display the data. . . . . . Step 1. Add a grid . . . . . . . . . . . .

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

. 34-7 . 34-8 . 34-8 34-10 .34-11 .34-11 .34-11 .34-11 34-12 34-12 34-12 34-13 34-13 34-13 34-14 34-14 34-15 34-15

. 33-15 . 33-15 . 33-16 . 33-17 . 33-17 . . . . . . 33-18 33-18 33-18 33-18 33-19 33-19

. 33-19

xviii

Step 2. Add editing commands to the grid . . . . . . . . . . . . . . . Add an edit form . . . . . . . . . . . . Step 1. Add a new Web page module . . . . . . . . . . . . . . . Step 2. Save the new module . . . Step 3. Make CountryTableU accessible to the new module . . Step 4. Add input fields . . . . . . Step 5. Add buttons. . . . . . . . . Step 6. Link form actions to the grid page . . . . . . . . . . . . . . Step 7. Link grid actions to the form page . . . . . . . . . . . . . Run the completed application . . . . Add error reporting . . . . . . . . . . Step 1. Add error support to the grid . . . . . . . . . . . . . . . Step 2. Add error support to the form . . . . . . . . . . . . . . Step 3. Test the error-reporting mechanism. . . . . . . . . . . . . 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 . . . . . . . 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. . . . .

. . . 34-17 . . . 34-18 . . . 34-18 . . . 34-18 . . . 34-18 . . . 34-18 . . . 34-19 . . . 34-20 . . . 34-20 . . . 34-21 . . . 34-21 . . . 34-21 . . . 34-22 . . . 34-22 . . . 34-23 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34-24 34-24 34-25 34-26 34-26 34-28 34-28 34-29 34-30 34-30 34-30 34-31 34-31 34-31 34-32 34-32 34-32 34-32 34-32 34-32 34-33 34-34 34-34

Using adapter components to generate content . . . . . . . . Receiving adapter requests and generating responses . . . . . Image request . . . . . . . . . . Image response. . . . . . . . . . Dispatching action items . . . . . . Page dispatcher operation . . . . .

. . . . 34-34 . . . . . . . . . . . . . . . . . . . . 34-35 34-37 34-37 34-38 34-38

Chapter 35

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 . Abstracting XML documents with the Data Binding wizard . . . . . . . . . . . Using the XML Data Binding wizard . Using code that the XML Data Binding wizard generates. . . . . . . . . . . . . . . . . . . . .

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

. . . 35-5 . . . 35-7 . . . 35-8

Chapter 36

Using Web ServicesUnderstanding invokable interfaces . . Using nonscalar types in invokable interfaces . . . . . . . . . . . . . . . Registering nonscalar types. . . . Registering typedefed types and enumerated types . . . . . . . . Using 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 Web Services Importer . . 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 . . . . .

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

. . . 36-14 . . . . . . . . . . . . 36-15 36-16 36-16 36-16

xix

Chapter 37

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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

37-1. 37-1 . 37-2 . 37-2 . 37-2 . 37-2 . 37-3 . 37-3 . 37-3 . 37-3 . 37-4

. . . . 37-4 . . . . 37-5 . . . . 37-5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37-6 . 37-6 . 37-6 . 37-6 . 37-6 . 37-7 . 37-7 . 37-7 . 37-7 . 37-7 . 37-7 . 37-8 . 37-8 . 37-8 . 37-9 . 37-9 . 37-9 . 37-9 37-10 37-10 37-10

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 . . . . . . . . . COM+ Event and event subscriber 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 . . . . .

. . . . 38-2 . . . . 38-2 . . . . 38-3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38-4 38-4 38-5 38-6

. 38-6 . 38-8 . 38-9 . 38-9 38-10 38-12 38-13 38-13 38-14 38-14 38-15 38-16 38-16 38-17 38-17 38-17 38-18 38-18

. . . 38-19 . . . 38-22

Chapter 39

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 . . . . . . . . . . Creating a new type library. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

39-1. 39-2 . 39-2 . 39-3 . 39-4 . 39-5 . 39-5 . 39-8 . 39-8 . 39-9 . 39-9 . 39-9 39-10 39-10 .39-11 39-12

Part IV

Developing COM-based applicationsChapter 38

Overview of COM technologies

38-1

COM as a specification and implementation . . . . . . . . . . . . . . 38-1

xx

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 . . . . . . . . Saving a type library . . . . . . . . Refreshing the type library . . . . Registering the type library . . . . Exporting an IDL file . . . . . . . . Deploying type libraries . . . . . . . . .

. . . 39-13 . . . 39-13 . . . 39-14 . . . 39-14 . . . 39-15 . . . 39-15 . . . 39-16 . . . 39-16 . . . 39-16 . . . 39-17 . . . . . . . . . . . . . . . . . . 39-17 39-18 39-18 39-18 39-19 39-19

Writing client code based on type library definitions . . . . . . . . . . . Connecting to a server . . . . . . . Controlling an Automation server using a dual interface . . . . . . . Controlling an Automation server usin


Recommended