1. Trang chủ
  2. » Công Nghệ Thông Tin

delphi 7 - developer's guide

1,1K 7,8K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1.113
Dung lượng 14,4 MB

Nội dung

Developer’s Guide Borland Software Corporation 100 Enterprise Way, Scotts Valley, CA 95066-3249 www.borland.com Borland ® Delphi7 for Windows ™ Refer to the DEPLOY document located in the root directory of your Delphi 7 product for a complete list of files that you can distribute in accordance with the Delphi 7 License Statement and Limited Warranty. Borland Software Corporation may have patents and/or pending patent applications covering subject matter in this document. Please refer to the product CD or the About dialog box for the list of applicable patents. The furnishing of this document does not give you any license to these patents. C OPYRIGHT © 1983–2002 Borland Software Corporation. All rights reserved. All Borland brand and product names are trademarks or registered trademarks of Borland Software Corporation in the United States and other countries. All other marks are the property of their respective owners. Printed in the U.S.A. HDE1370WW21001 7E5R0802 0203040506-9 8 7654321 D3 iii Chapter 1 Introduction 1-1 What’s in this manual? . . . . . . . . . . . . . . 1-1 Manual conventions . . . . . . . . . . . . . . . . 1-2 Developer support services. . . . . . . . . . . . 1-3 Part I Programming with Delphi Chapter 2 Developing applications with Delphi 2-1 Integrated development environment. . . . . . 2-1 Designing applications . . . . . . . . . . . . . . 2-2 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 library 3-1 Understanding the component library . . . . . 3-1 Properties, methods, and events . . . . . . . 3-3 Properties . . . . . . . . . . . . . . . . . . 3-3 Methods . . . . . . . . . . . . . . . . . . 3-4 Events . . . . . . . . . . . . . . . . . . . . 3-4 User events . . . . . . . . . . . . . . . . . 3-4 System events . . . . . . . . . . . . . . . 3-4 Internal events . . . . . . . . . . . . . . . 3-4 Objects, components, and controls. . . . . . . . 3-5 TObject branch . . . . . . . . . . . . . . . . . 3-6 TPersistent branch . . . . . . . . . . . . . . . 3-7 TComponent branch . . . . . . . . . . . . . . 3-7 TControl branch . . . . . . . . . . . . . . . . 3-9 TWinControl/TWidgetControl branch . . .3-10 Chapter 4 Using the object model 4-1 What is an object? . . . . . . . . . . . . . . . . . 4-1 Examining a Delphi object . . . . . . . . . . 4-2 Changing the name of a component . . . . . 4-4 Inheriting data and code from an object. . . . . 4-5 Scope and qualifiers . . . . . . . . . . . . . . . . 4-5 Private, protected, public, and published declarations . . . . . . . . . . . . . . . . . . 4-6 Using object variables . . . . . . . . . . . . . . 4-7 Creating, instantiating, and destroying objects . . . . . . . . . . . . . . . . . . . . . . 4-8 Components and ownership . . . . . . . . . 4-9 Defining new classes . . . . . . . . . . . . . . . 4-9 Using interfaces . . . . . . . . . . . . . . . . . . 4-12 Using interfaces across the hierarchy . . . . 4-13 Using interfaces with procedures . . . . . . 4-14 Implementing IInterface . . . . . . . . . . . 4-14 TInterfacedObject . . . . . . . . . . . . . . . 4-15 Using the as operator with interfaces . . . . 4-16 Reusing code and delegation. . . . . . . . . 4-16 Using implements for delegation . . . . 4-17 Aggregation . . . . . . . . . . . . . . . . 4-18 Memory management of interface objects. . . . . . . . . . . . . . . . . . . . . 4-18 Using reference counting . . . . . . . . 4-19 Not using reference counting . . . . . . 4-20 Using interfaces in distributed applications . . . . . . . . . . . . . . . . . 4-21 Chapter 5 Using BaseCLX 5-1 Using streams . . . . . . . . . . . . . . . . . . . 5-2 Using streams to read or write data . . . . . 5-2 Stream methods for reading and writing . . . . . . . . . . . . . . . 5-2 Reading and writing components . . . 5-3 Reading and writing strings . . . . . . . 5-3 Copying data from one stream to another. . . . . . . . . . . . . . . . . . . 5-4 Specifying the stream position and size. . . 5-4 Seeking to a specific position . . . . . . 5-4 Using Position and Size properties . . . 5-5 Working with files . . . . . . . . . . . . . . . . 5-5 Approaches to file I/O . . . . . . . . . . . . 5-6 Using file streams . . . . . . . . . . . . . . . 5-6 Creating and opening files using file streams . . . . . . . . . . . . . . . 5-7 Using the file handle . . . . . . . . . . . 5-8 Manipulating files. . . . . . . . . . . . . . . 5-8 Deleting a file . . . . . . . . . . . . . . . 5-8 Finding a file . . . . . . . . . . . . . . . 5-8 Renaming a file . . . . . . . . . . . . . . 5-10 File date-time routines . . . . . . . . . . 5-10 Copying a file . . . . . . . . . . . . . . . 5-11 Contents iv Working with ini files and the system Registry . . . . . . . . . . . . . . . . . . . . . 5-11 Using TIniFile and TMemIniFile . . . . 5-12 Using TRegistryIniFile . . . . . . . . . 5-13 Using TRegistry . . . . . . . . . . . . . 5-13 Working with lists . . . . . . . . . . . . . . . . 5-14 Common list operations . . . . . . . . . . . 5-15 Adding list items . . . . . . . . . . . . 5-15 Deleting list items . . . . . . . . . . . . 5-15 Accessing list items . . . . . . . . . . . 5-16 Rearranging list items . . . . . . . . . . 5-16 Persistent lists. . . . . . . . . . . . . . . . . 5-16 Working with string lists . . . . . . . . . . . . 5-17 Loading and saving string lists . . . . . . . 5-17 Creating a new string list . . . . . . . . . . 5-18 Short-term string lists . . . . . . . . . . 5-18 Long-term string lists . . . . . . . . . . 5-18 Manipulating strings in a list . . . . . . . . 5-20 Counting the strings in a list . . . . . . 5-20 Accessing a particular string . . . . . . 5-20 Locating items in a string list . . . . . . 5-20 Iterating through strings in a list . . . . 5-20 Adding a string to a list . . . . . . . . . 5-21 Moving a string within a list . . . . . . 5-21 Deleting a string from a list . . . . . . . 5-21 Associating objects with a string list . . . . . . . . . . . . . . . . 5-22 Working with strings . . . . . . . . . . . . . . 5-22 Wide character routines . . . . . . . . . . . 5-22 Commonly used long string routines . . . 5-23 Commonly used routines for null-terminated strings. . . . . . . . . . . 5-26 Declaring and initializing strings. . . . . . 5-27 Mixing and converting string types . . . . 5-28 String to PChar conversions. . . . . . . . . 5-28 String dependencies . . . . . . . . . . . 5-29 Returning a PChar local variable . . . 5-29 Passing a local variable as a PChar . . . . . . . . . . . . . . . . . 5-29 Compiler directives for strings . . . . . . . 5-30 Creating drawing spaces . . . . . . . . . . . . 5-31 Printing . . . . . . . . . . . . . . . . . . . . . . 5-32 Converting measurements . . . . . . . . . . . 5-33 Performing conversions . . . . . . . . . . . 5-33 Performing simple conversions . . . . 5-33 Performing complex conversions . . . 5-33 Adding new measurement types . . . . . . 5-34 Creating a simple conversion family and adding units. . . . . . . . . . . . . . . 5-34 Declare variables . . . . . . . . . . . . . 5-35 Register the conversion family . . . . . 5-35 Register measurement units . . . . . . . 5-35 Use the new units . . . . . . . . . . . . . 5-35 Using a conversion function . . . . . . . . . 5-36 Declare variables . . . . . . . . . . . . . 5-36 Register the conversion family . . . . . 5-36 Register the base unit . . . . . . . . . . 5-36 Write methods to convert to and from the base unit . . . . . . . . . . . . 5-36 Register the other units . . . . . . . . . 5-37 Use the new units . . . . . . . . . . . . . 5-37 Using a class to manage conversions . . . . 5-37 Creating the conversion class . . . . . . 5-38 Declare variables . . . . . . . . . . . . . 5-39 Register the conversion family and the other units . . . . . . . . . . . . . . 5-39 Use the new units . . . . . . . . . . . . . 5-40 Defining custom variants . . . . . . . . . . . . 5-40 Storing a custom variant type’s data . . . . 5-41 Creating a class to enable the custom variant type . . . . . . . . . . . . . 5-42 Enabling casting . . . . . . . . . . . . . 5-42 Implementing binary operations . . . . 5-44 Implementing comparison operations . . . . . . . . . . . . . . . . 5-46 Implementing unary operations . . . . 5-47 Copying and clearing custom variants . . . 5-48 Loading and saving custom variant values . . . . . . . . . . . . . . 5-49 Using the TCustomVariantType descendant . . . . . . . . . . . . . . . . 5-50 Writing utilities to work with a custom variant type . . . . . . . . . . . . . 5-50 Supporting properties and methods in custom variants . . . . . . . . . . . . . . 5-51 Using TInvokeableVariantType . . . . . 5-51 Using TPublishableVariantType . . . . 5-53 Chapter 6 Working with components 6-1 Setting component properties . . . . . . . . . . 6-2 Setting properties at design time . . . . . . 6-2 Using property editors . . . . . . . . . . 6-3 Setting properties at runtime. . . . . . . . . 6-3 Calling methods. . . . . . . . . . . . . . . . . . 6-3 v Working with events and event handlers . . . . 6-3 Generating a new event handler . . . . . . . 6-4 Generating a handler for a component’s default event . . . . . . . . . 6-4 Locating event handlers . . . . . . . . . . . . 6-4 Associating an event with an existing event handler . . . . . . . . . . . . . . . . . 6-5 Using the Sender parameter . . . . . . . 6-5 Displaying and coding shared events . . . . . . . . . . . . . . . . . . . 6-5 Associating menu events with event handlers . . . . . . . . . . . . . . . . 6-6 Deleting event handlers . . . . . . . . . . . . 6-6 Cross-platform and non-cross-platform components . . . . . . . . . . . . . . . . . . . . 6-7 Adding custom components to the Component palette . . . . . . . . . . . . . . 6-9 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-3 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-5 Controlling how child controls are docked . . . . . . . . . . . . . . . . . . . 7-5 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-9 Selecting all text . . . . . . . . . . . . . . . . 7-9 Cutting, copying, and pasting text . . . . . 7-10 Deleting selected text . . . . . . . . . . . . 7-10 Disabling menu items . . . . . . . . . . . . 7-11 Providing a pop-up menu . . . . . . . . . . 7-11 Handling the OnPopup event. . . . . . . . 7-12 Adding graphics to controls . . . . . . . . . . . 7-13 Indicating that a control is owner-drawn. . . . . . . . . . . . . . . . . 7-13 Adding graphical objects to a string list . . . . . . . . . . . . . . . . . . 7-14 Adding images to an application . . . . 7-14 Adding images to a string list . . . . . . 7-14 Drawing owner-drawn items . . . . . . 7-15 Sizing owner-draw items. . . . . . . . . . . 7-16 Drawing owner-draw items . . . . . . . . . 7-17 Chapter 8 Building applications, components, and libraries 8-1 Creating applications. . . . . . . . . . . . . . . 8-1 GUI applications. . . . . . . . . . . . . . . . 8-2 User interface models . . . . . . . . . . 8-2 SDI applications . . . . . . . . . . . . . 8-2 MDI applications . . . . . . . . . . . . . 8-2 Setting IDE, project, and compiler options . . . . . . . . . . . . . . . . . . 8-3 Programming templates . . . . . . . . . . . 8-3 Console applications . . . . . . . . . . . . . 8-4 Service applications . . . . . . . . . . . . . . 8-5 Service threads . . . . . . . . . . . . . . 8-8 Service name properties . . . . . . . . . 8-9 Debugging service applications . . . . . 8-10 Creating packages and DLLs . . . . . . . . . . 8-11 When to use packages and DLLs . . . . . . 8-11 Writing database applications . . . . . . . . . . 8-12 Distributing database applications . . . . . 8-13 Creating Web server applications . . . . . . . . 8-13 Creating Web Broker applications . . . . . . 8-14 Creating WebSnap applications . . . . . . . 8-15 Creating Web Services applications . . . . . 8-15 Writing applications using COM . . . . . . . . 8-16 Using COM and DCOM . . . . . . . . . . . 8-16 Using MTS and COM+ . . . . . . . . . . . . 8-16 Using data modules . . . . . . . . . . . . . . . 8-17 Creating and editing standard data modules. . . . . . . . . . . . . . . . . . . . 8-17 Naming a data module and its unit file . . . . . . . . . . . . . . . . 8-18 Placing and naming components . . . . 8-19 Using component properties and events in a data module . . . . . . . . 8-19 Creating business rules in a data module . . . . . . . . . . . . . . . 8-20 vi Accessing a data module from a form . . . 8-20 Adding a remote data module to an application server project . . . . . . . . . 8-21 Using the Object Repository . . . . . . . . . . 8-21 Sharing items within a project . . . . . . . 8-21 Adding items to the Object Repository . . . . . . . . . . . . . . . . . . 8-22 Sharing objects in a team environment. . . . . . . . . . . . . . . . . 8-22 Using an Object Repository item in a project . . . . . . . . . . . . . . . . . . . 8-22 Copying an item . . . . . . . . . . . . . 8-22 Inheriting an item . . . . . . . . . . . . 8-23 Using an item . . . . . . . . . . . . . . 8-23 Using project templates . . . . . . . . . . . 8-23 Modifying shared items . . . . . . . . . . . 8-23 Specifying a default project, new form, and main form . . . . . . . . . . . . . . . 8-24 Enabling Help in applications . . . . . . . . . 8-24 Help system interfaces. . . . . . . . . . . . 8-25 Implementing ICustomHelpViewer . . . . 8-25 Communicating with the Help Manager . . . . . . . . . . . . . . . . . . . 8-26 Asking the Help Manager for information . . . . . . . . . . . . . . . . . 8-26 Displaying keyword-based Help . . . . . . 8-27 Displaying tables of contents . . . . . . . . 8-28 Implementing IExtendedHelpViewer . . . 8-28 Implementing IHelpSelector . . . . . . . . 8-29 Registering Help system objects . . . . . . 8-30 Registering Help viewers . . . . . . . . 8-30 Registering Help selectors . . . . . . . 8-30 Using Help in a VCL application. . . . . . . . 8-31 How TApplication processes VCL Help . . . . . . . . . . . . . . . . . . 8-31 How VCL controls process Help . . . . . . 8-31 Using Help in a CLX application. . . . . . . . 8-32 How TApplication processes CLX Help . . . . . . . . . . . . . . . . . . 8-32 How CLX controls process Help . . . . . . 8-32 Calling a Help system directly . . . . . . . . . 8-33 Using IHelpSystem . . . . . . . . . . . . . . . 8-33 Customizing the IDE Help system. . . . . . . 8-34 Chapter 9 Developing the application user interface 9-1 Controlling application behavior . . . . . . . . 9-1 Working at the application level . . . . . . . 9-2 Handling the screen. . . . . . . . . . . . . . 9-2 Setting up forms. . . . . . . . . . . . . . . . . . 9-3 Using the main form . . . . . . . . . . . . . 9-3 Hiding the main form. . . . . . . . . . . . . 9-3 Adding forms . . . . . . . . . . . . . . . . . 9-4 Linking forms . . . . . . . . . . . . . . . 9-4 Avoiding circular unit references . . . . 9-4 Managing layout . . . . . . . . . . . . . . . 9-5 Using forms . . . . . . . . . . . . . . . . . . . . 9-6 Controlling when forms reside in memory . . . . . . . . . . . . . . . . . . 9-6 Displaying an auto-created form . . . . 9-6 Creating forms dynamically . . . . . . . 9-7 Creating modeless forms such as windows . . . . . . . . . . . . . . . 9-8 Creating a form instance using a local variable . . . . . . . . . . . . . 9-8 Passing additional arguments to forms . . . 9-8 Retrieving data from forms. . . . . . . . . . 9-9 Retrieving data from modeless forms . . . . . . . . . . . . . . . . . . . 9-9 Retrieving data from modal forms . . . 9-11 Reusing components and groups of components . . . . . . . . . . . . . . . . . . . 9-13 Creating and using component templates . . . . . . . . . . . . . . . . . . . . . 9-13 Working with frames . . . . . . . . . . . . . . . 9-14 Creating frames . . . . . . . . . . . . . . . . 9-14 Adding frames to the Component palette. . . . . . . . . . . . . . . . . . . . . 9-15 Using and modifying frames. . . . . . . . . 9-15 Sharing frames. . . . . . . . . . . . . . . . . 9-16 Developing dialog boxes . . . . . . . . . . . . . 9-17 Using open dialog boxes . . . . . . . . . . . 9-17 Organizing actions for toolbars and menus . . . . . . . . . . . . . . . . . . . . 9-18 What is an action? . . . . . . . . . . . . . . . 9-19 Setting up action bands . . . . . . . . . . . . 9-20 vii Creating toolbars and menus . . . . . . . . 9-20 Adding color, patterns, or pictures to menus, buttons, and toolbars . . . 9-22 Adding icons to menus and toolbars . . . . . . . . . . . . . . . . . 9-22 Selecting menu and toolbar styles . . . 9-23 Creating dynamic menus . . . . . . . . 9-24 Creating toolbars and menus that users can customize . . . . . . . . . . 9-24 Hiding unused items and categories in action bands . . . . . . . . . . . . . 9-24 Creating most recently used (MRU) lists . . . . . . . . . . . . . . . 9-25 Using action lists . . . . . . . . . . . . . . . . . 9-26 Setting up action lists . . . . . . . . . . . . 9-26 What happens when an action fires . . . . 9-27 Responding with events . . . . . . . . 9-27 How actions find their targets . . . . . 9-29 Updating actions . . . . . . . . . . . . . . . 9-29 Predefined action classes . . . . . . . . . . 9-30 Writing action components . . . . . . . . . 9-31 Registering actions . . . . . . . . . . . . . . 9-31 Creating and managing menus. . . . . . . . . 9-32 Opening the Menu Designer . . . . . . . . 9-33 Building menus. . . . . . . . . . . . . . . . 9-34 Naming menus . . . . . . . . . . . . . 9-34 Naming the menu items . . . . . . . . 9-34 Adding, inserting, and deleting menu items . . . . . . . . . . . . . . . 9-35 Adding separator bars . . . . . . . . . 9-36 Specifying accelerator keys and keyboard shortcuts . . . . . . . . . . 9-36 Creating submenus. . . . . . . . . . . . . . 9-37 Creating submenus by demoting existing menus . . . . . . . . . . . . . 9-37 Moving menu items . . . . . . . . . . . 9-38 Adding images to menu items . . . . . 9-38 Viewing the menu . . . . . . . . . . . . 9-39 Editing menu items in the Object Inspector. . . . . . . . . . . . . . . . . . . 9-39 Using the Menu Designer context menu . . . . . . . . . . . . . . . . . . . . . 9-40 Commands on the context menu . . . 9-40 Switching between menus at design time . . . . . . . . . . . . . . . 9-41 Using menu templates . . . . . . . . . . . . 9-41 Saving a menu as a template . . . . . . . . 9-43 Naming conventions for template menu items and event handlers . . . 9-44 Manipulating menu items at runtime . . . . 9-44 Merging menus . . . . . . . . . . . . . . . . 9-44 Specifying the active menu: Menu property . . . . . . . . . . . . . . . . . 9-45 Determining the order of merged menu items: GroupIndex property . . . . . . 9-45 Importing resource files . . . . . . . . . . . 9-45 Designing toolbars and cool bars . . . . . . . . 9-46 Adding a toolbar using a panel component . . . . . . . . . . . . . . . . . . 9-47 Adding a speed button to a panel . . . 9-47 Assigning a speed button’s glyph . . . 9-48 Setting the initial condition of a speed button . . . . . . . . . . . . . . . 9-48 Creating a group of speed buttons . . . 9-48 Allowing toggle buttons . . . . . . . . . 9-49 Adding a toolbar using the toolbar component . . . . . . . . . . . . . . . . . . 9-49 Adding a tool button . . . . . . . . . . . 9-49 Assigning images to tool buttons . . . . 9-50 Setting tool button appearance and initial conditions . . . . . . . . . . . . 9-50 Creating groups of tool buttons . . . . . 9-51 Allowing toggled tool buttons . . . . . 9-51 Adding a cool bar component . . . . . . . . 9-51 Setting the appearance of the cool bar . . . . . . . . . . . . . . . . . . 9-52 Responding to clicks . . . . . . . . . . . . . 9-52 Assigning a menu to a tool button . . . 9-52 Adding hidden toolbars . . . . . . . . . . . 9-53 Hiding and showing toolbars . . . . . . . . 9-53 Demo programs . . . . . . . . . . . . . . . . 9-53 Common controls and XP themes. . . . . . . . 9-54 Chapter 10 Types of controls 10-1 Text controls . . . . . . . . . . . . . . . . . . . . 10-1 Edit controls . . . . . . . . . . . . . . . . . . 10-1 Memo and rich edit controls . . . . . . 10-2 Text viewing controls . . . . . . . . . . . . . 10-3 Labels . . . . . . . . . . . . . . . . . . . . . . 10-3 Specialized input controls . . . . . . . . . . . . 10-4 Scroll bars . . . . . . . . . . . . . . . . . . . 10-4 Track bars. . . . . . . . . . . . . . . . . . . . 10-5 Up-down controls . . . . . . . . . . . . . . . 10-5 Spin edit controls (CLX only) . . . . . . . . 10-5 Hot key controls (VCL only) . . . . . . . . . 10-6 Splitter controls . . . . . . . . . . . . . . . . 10-6 viii Buttons and similar controls . . . . . . . . . . 10-6 Button controls . . . . . . . . . . . . . . . . 10-7 Bitmap buttons . . . . . . . . . . . . . . . . 10-7 Speed buttons. . . . . . . . . . . . . . . . . 10-8 Check boxes. . . . . . . . . . . . . . . . . . 10-8 Radio buttons . . . . . . . . . . . . . . . . . 10-8 Toolbars . . . . . . . . . . . . . . . . . . . . 10-9 Cool bars (VCL only). . . . . . . . . . . . . 10-9 List controls. . . . . . . . . . . . . . . . . . . . 10-9 List boxes and check-list boxes . . . . . . . 10-10 Combo boxes . . . . . . . . . . . . . . . . . 10-11 Tree views . . . . . . . . . . . . . . . . . . . 10-11 List views . . . . . . . . . . . . . . . . . . . 10-12 Icon views (CLX only) . . . . . . . . . . . . 10-12 Date-time pickers and month calendars. . . . . . . . . . . . . . . . . . . 10-12 Grouping controls . . . . . . . . . . . . . . . . 10-12 Group boxes and radio groups . . . . . . . 10-13 Panels . . . . . . . . . . . . . . . . . . . . . 10-13 Scroll boxes . . . . . . . . . . . . . . . . . . 10-13 Tab controls . . . . . . . . . . . . . . . . . . 10-14 Page controls . . . . . . . . . . . . . . . . . 10-14 Header controls. . . . . . . . . . . . . . . . 10-14 Display controls . . . . . . . . . . . . . . . . . 10-15 Status bars. . . . . . . . . . . . . . . . . . . 10-15 Progress bars . . . . . . . . . . . . . . . . . 10-15 Help and hint properties . . . . . . . . . . 10-16 Grids. . . . . . . . . . . . . . . . . . . . . . . . 10-16 Draw grids . . . . . . . . . . . . . . . . . . 10-16 String grids . . . . . . . . . . . . . . . . . . 10-16 Value list editors (VCL only) . . . . . . . . . . 10-17 Graphic controls . . . . . . . . . . . . . . . . . 10-18 Images . . . . . . . . . . . . . . . . . . . . . 10-18 Shapes . . . . . . . . . . . . . . . . . . . . . 10-18 Bevels . . . . . . . . . . . . . . . . . . . . . 10-18 Paint boxes . . . . . . . . . . . . . . . . . . 10-19 Animation control . . . . . . . . . . . . . . 10-19 Chapter 11 Designing classes and components with ModelMaker 11-1 ModelMaker fundamentals. . . . . . . . . . . 11-2 ModelMaker models . . . . . . . . . . . . . 11-2 Using ModelMaker with the IDE. . . . . . 11-2 Creating models . . . . . . . . . . . . . . . 11-3 Using ModelMaker views . . . . . . . . . . . . 11-4 Collections pane . . . . . . . . . . . . . . . . 11-5 Classes view . . . . . . . . . . . . . . . . 11-5 Units view . . . . . . . . . . . . . . . . . 11-5 Diagrams view . . . . . . . . . . . . . . 11-6 Members pane . . . . . . . . . . . . . . . . . 11-7 Editors pane . . . . . . . . . . . . . . . . . . 11-7 Implementation Editor . . . . . . . . . . 11-7 Unit Code Editor . . . . . . . . . . . . . 11-8 Diagram Editor . . . . . . . . . . . . . . 11-9 Other Editors . . . . . . . . . . . . . . . 11-9 For more information. . . . . . . . . . . . . . 11-10 Chapter 12 Working with graphics and multimedia 12-1 Overview of graphics programming . . . . . . 12-1 Refreshing the screen . . . . . . . . . . . . . 12-2 Types of graphic objects . . . . . . . . . . . 12-3 Common properties and methods of Canvas . . . . . . . . . . . . . . . . . . . 12-4 Using the properties of the Canvas object . . . . . . . . . . . . . . . . . . . . . 12-5 Using pens . . . . . . . . . . . . . . . . 12-5 Using brushes . . . . . . . . . . . . . . . 12-8 Reading and setting pixels . . . . . . . 12-9 Using Canvas methods to draw graphic objects . . . . . . . . . . . . . . . 12-10 Drawing lines and polylines . . . . . 12-10 Drawing shapes . . . . . . . . . . . . . 12-11 Handling multiple drawing objects in your application . . . . . . . . . . . . 12-12 Keeping track of which drawing tool to use . . . . . . . . . . . . . . . 12-12 Changing the tool with speed buttons . . . . . . . . . . . . . . . . . 12-13 Using drawing tools . . . . . . . . . . 12-14 Drawing on a graphic. . . . . . . . . . . . 12-16 Making scrollable graphics . . . . . . 12-17 Adding an image control . . . . . . . 12-17 Loading and saving graphics files. . . . . 12-19 Loading a picture from a file . . . . . 12-19 Saving a picture to a file . . . . . . . . 12-20 Replacing the picture . . . . . . . . . . 12-20 ix Using the clipboard with graphics . . . . . 12-21 Copying graphics to the clipboard . . . . . . . . . . . . . . . . 12-22 Cutting graphics to the clipboard . . . 12-22 Pasting graphics from the clipboard . . . . . . . . . . . . . . . . 12-23 Rubber banding example . . . . . . . . . . 12-24 Responding to the mouse . . . . . . . . 12-24 Responding to a mouse-down action . . . . . . . . . . . . . . . . . . 12-25 Adding a field to a form object to track mouse actions . . . . . . . . . . 12-27 Refining line drawing . . . . . . . . . . 12-28 Working with multimedia . . . . . . . . . . . 12-30 Adding silent video clips to an application. . . . . . . . . . . . . . . . . . 12-30 Example of adding silent video clips . . . . . . . . . . . . . . . 12-31 Adding audio and/or video clips to an application . . . . . . . . . . . . . . . . 12-32 Example of adding audio and/or video clips (VCL only) . . . . . . . . 12-33 Chapter 13 Writing multi-threaded applications 13-1 Defining thread objects . . . . . . . . . . . . . 13-2 Initializing the thread . . . . . . . . . . . . 13-3 Assigning a default priority . . . . . . 13-3 Indicating when threads are freed . . . 13-4 Writing the thread function . . . . . . . . . 13-4 Using the main VCL/CLX thread . . . 13-4 Using thread-local variables . . . . . . 13-6 Checking for termination by other threads . . . . . . . . . . . . . . . . . 13-6 Handling exceptions in the thread function . . . . . . . . . . . . . . . . . 13-6 Writing clean-up code . . . . . . . . . . . . 13-7 Coordinating threads . . . . . . . . . . . . . . 13-7 Avoiding simultaneous access . . . . . . . 13-7 Locking objects . . . . . . . . . . . . . 13-8 Using critical sections . . . . . . . . . . 13-8 Using the multi-read exclusive-write synchronizer . . . . . . . . . . . . . . 13-8 Other techniques for sharing memory . . . . . . . . . . . . . . . . . 13-9 Waiting for other threads . . . . . . . . . . 13-9 Waiting for a thread to finish executing . . . . . . . . . . . . . . . . 13-10 Waiting for a task to be completed . . . . . . . . . . . . . . . 13-10 Executing thread objects . . . . . . . . . . . . 13-12 Overriding the default priority . . . . . . 13-12 Starting and stopping threads . . . . . . . 13-12 Debugging multi-threaded applications . . . 13-13 Naming a thread. . . . . . . . . . . . . . . 13-13 Converting an unnamed thread to a named thread . . . . . . . . . . 13-13 Assigning separate names to similar threads . . . . . . . . . . . . 13-15 Chapter 14 Exception handling 14-1 Defining protected blocks . . . . . . . . . . . . 14-2 Writing the try block . . . . . . . . . . . . . 14-2 Raising an exception . . . . . . . . . . . 14-3 Writing exception handlers. . . . . . . . . . 14-4 Exception-handling statements . . . . . 14-4 Handling classes of exceptions . . . . . 14-6 Scope of exception handlers . . . . . . . 14-6 Reraising exceptions . . . . . . . . . . . 14-7 Writing finally blocks . . . . . . . . . . . . . 14-8 Writing a finally block . . . . . . . . . . 14-9 Handling exceptions in VCL applications . . . . . . . . . . . . . . . . . . . 14-9 VCL exception classes . . . . . . . . . . . 14-10 Default exception handling in VCL . . . . 14-11 Silent exceptions. . . . . . . . . . . . . . . 14-12 Defining your own VCL exceptions. . . . 14-13 Chapter 15 Developing cross-platform applications 15-1 Creating CLX applications . . . . . . . . . . . . 15-2 Porting VCL applications . . . . . . . . . . . . 15-2 Porting techniques . . . . . . . . . . . . . . 15-2 Platform-specific ports . . . . . . . . . . 15-3 Cross-platform ports . . . . . . . . . . . 15-3 Windows emulation ports . . . . . . . . 15-3 Modifying VCL applications. . . . . . . . . 15-4 WinCLX versus VisualCLX. . . . . . . . . . 15-5 What VisualCLX does differently . . . . 15-6 Features that do not port directly or are missing . . . . . . . . . . . . . . . . 15-7 Comparing WinCLX and VisualCLX units . . . . . . . . . . . . . . . 15-8 Differences in CLX object constructors . . 15-11 Handling system and widget events . . . 15-12 x Writing portable code . . . . . . . . . . . . 15-12 Using conditional directives . . . . . . 15-13 Terminating conditional directives . . . . . . . . . . . . . . . . 15-14 Including inline assembler code . . . . 15-15 Programming differences on Linux . . . . 15-16 Transferring applications between Windows and Linux . . . . . . . . . . . . . . 15-17 Sharing source files between Windows and Linux . . . . . . . . . . . . 15-17 Environmental differences between Windows and Linux . . . . . . . . . . . . 15-18 Registry . . . . . . . . . . . . . . . . . . 15-20 Look and feel . . . . . . . . . . . . . . . 15-20 Directory structure on Linux . . . . . . . . 15-20 Cross-platform database applications . . . . . 15-21 dbExpress differences . . . . . . . . . . . . 15-22 Component-level differences . . . . . . . . 15-22 User interface-level differences . . . . . . . 15-23 Porting database applications to Linux . . . . . . . . . . . . . . . . . . . 15-24 Updating data in dbExpress applications . . . . . . . . . . . . . . . . . 15-26 Cross-platform Internet applications . . . . . 15-28 Porting Internet applications to Linux . . . . . . . . . . . . . . . . . . . 15-28 Chapter 16 Working with packages and components 16-1 Why use packages? . . . . . . . . . . . . . . . 16-2 Packages and standard DLLs . . . . . . . . 16-2 Runtime packages . . . . . . . . . . . . . . . . 16-3 Loading packages in an application . . . . 16-3 Loading packages with the LoadPackage function . . . . . . . . . . 16-4 Deciding which runtime packages to use. . . . . . . . . . . . . . . . . . . . . 16-4 Custom packages. . . . . . . . . . . . . . . 16-5 Design-time packages . . . . . . . . . . . . . . 16-5 Installing component packages . . . . . . . 16-6 Creating and editing packages . . . . . . . . . 16-7 Creating a package . . . . . . . . . . . . . . 16-7 Editing an existing package . . . . . . . . . 16-8 Understanding the structure of a package . . . . . . . . . . . . . . . . . . 16-8 Naming packages . . . . . . . . . . . . 16-8 Requires clause . . . . . . . . . . . . . 16-9 Contains clause . . . . . . . . . . . . . 16-9 Editing package source files manually . . . . . . . . . . . . . . . . . . 16-10 Compiling packages . . . . . . . . . . . . 16-10 Package-specific compiler directives . . . . . . . . . . . . . . . . 16-11 Compiling and linking from the command line . . . . . . . . . . . . . 16-13 Package files created when compiling . . . . . . . . . . . . . . . 16-13 Deploying packages . . . . . . . . . . . . . . 16-14 Deploying applications that use packages . . . . . . . . . . . . . . . . . . 16-14 Distributing packages to other developers . . . . . . . . . . . . . . . . . 16-14 Package collection files . . . . . . . . . . . 16-14 Chapter 17 Creating international applications 17-1 Internationalization and localization . . . . . . 17-1 Internationalization . . . . . . . . . . . . . . 17-1 Localization . . . . . . . . . . . . . . . . . . 17-2 Internationalizing applications . . . . . . . . . 17-2 Enabling application code . . . . . . . . . . 17-2 ~Character sets . . . . . . . . . . . . . . 17-2 OEM and ANSI character sets . . . . . 17-3 Multibyte character sets . . . . . . . . . 17-3 Wide characters . . . . . . . . . . . . . . 17-4 Including bi-directional functionality in applications . . . . . . . . . . . . . . 17-4 BiDiMode property . . . . . . . . . . . . 17-4 Locale-specific features . . . . . . . . . 17-7 Designing the user interface . . . . . . . . . 17-7 Text . . . . . . . . . . . . . . . . . . . . . 17-7 Graphic images . . . . . . . . . . . . . . 17-8 Formats and sort order . . . . . . . . . . 17-8 Keyboard mappings . . . . . . . . . . . 17-8 Isolating resources. . . . . . . . . . . . . . . 17-8 Creating resource DLLs. . . . . . . . . . . . 17-9 Using resource DLLs . . . . . . . . . . . . 17-10 Dynamic switching of resource DLLs. . . 17-11 Localizing applications. . . . . . . . . . . . . 17-12 Localizing resources. . . . . . . . . . . . . 17-12 [...]... Obtaining aggregate values 2 9-1 2 9-2 2 9-2 2 9-2 2 9-5 2 9-5 2 9-6 29 -7 29 -7 2 9-8 2 9-8 2 9-9 2 9-9 2 9-1 0 2 9-1 1 2 9-1 1 2 9-1 2 2 9-1 3 2 9-1 4 xvii 2 9-1 4 2 9-1 4 2 9-1 5 2 9-1 5 2 9-1 6 2 9- 17 2 9-1 8 2 9-1 9 2 9-2 0 2 9-2 0 2 9-2 1 2 9-2 3 2 9-2 4 2 9-2 5 2 9-2 6 2 9-2 6 2 9- 27 2 9- 27 2 9-2 8 2 9-2 9 2 9-2 9 2 9-3 0 2 9-3 1 2 9-3 1 2 9-3 2 2 9-3 3 2 9-3 3 2 9-3 4 2 9-3 4 2 9-3 5 2 9-3 5 2 9-3 6 2 9-3 6 Chapter 30 Using provider... 3 9-5 3 9-5 3 9-6 3 9-6 3 9-6 39 -7 39 -7 39 -7 39 -7 39 -7 3 9-8 3 9-8 3 9-8 3 9-8 3 9-8 3 9-9 3 9-9 3 9-9 3 9-9 3 9-1 0 3 9-1 0 3 9-1 0 3 9-1 1 3 9-1 1 xxii 4 0-1 4 0-2 4 0-2 4 0-3 4 0-3 4 0-4 4 0-5 4 0-5 4 0-6 40 -7 4 0-8 4 0-9 4 0-1 0 4 0-1 0 4 0-1 2 4 0-1 3 4 0-1 3 4 0-1 4... 3 4-1 1 3 4-1 1 3 4-1 1 3 4-1 2 3 4-1 2 3 4-1 2 3 4-1 2 3 4-1 3 3 4-1 3 3 4-1 3 3 4-1 4 3 4-1 4 3 4-1 5 3 4-1 6 3 4-1 6 3 4- 17 3 4-1 8 3 4-1 8 xx 3 5-1 3 5-2 3 5-2 3 5-3 3 5-4 3 5-5 3 5-5 3 5-6 3 5-6 3 5-6 3 5-6 3 5-6 35 -7 3 5-8 3 5-9 3 5-1 0 3 5-1 1 3 5-1 2 3 5-1 3 3 5-1 3 3 5-1 4 3 5-1 5 3 5- 17 3 5- 17 3 5-1 8 3 5-1 8 3 5-1 9 Server-side scripting in WebSnap Active... 2 3-1 2 3-1 3 2 3-1 4 2 3-1 4 2 3-1 4 2 3-1 4 2 3-1 5 2 4-2 2 4-3 2 4-4 2 4-5 2 4-6 24 -7 24 -7 2 4-8 2 4-8 2 4-9 2 4-9 2 4-9 2 4-1 0 2 4-1 0 2 4-1 0 2 4-1 0 2 4-1 0 2 4-1 1 2 4-1 1 2 4-1 2 2 4-1 3 2 4-1 3 2 4-1 3 2 4-1 4 Understanding datasets 2 2-1 8 Chapter 24 2 2- 17 2 3-2 2 3-3 2 3-3 2 3-4 2 3-4 2 3-6 23 -7 2 3-8 2 3-8 ... Setting tool buttons’ appearance Setting a cool button’s appearance 1-2 3-1 3-5 5-5 5 -7 5 -7 5 -7 5-9 5-1 4 5-2 4 5-2 5 5-2 5 5-2 5 5-2 6 5-2 6 5-2 6 5-2 6 5- 27 5-3 0 6 -7 7- 9 7- 13 8-1 1 8-1 2 8-1 4 8-1 8 8-3 1 9-1 8 9-2 5 9-3 0 9-3 1 9-3 4 9-4 0 9-4 8 9-5 0 9-5 2 10.1 Edit control properties 12.1 Graphic object types 12.2 Common... transactional objects 4 6-1 4 6-2 4 6-3 4 6-3 4 6-4 4 6-4 4 6-5 4 6-6 4 6-6 4 6-8 4 6-8 4 6-9 4 6-1 0 4 6-1 1 4 6-1 1 4 6-1 2 4 6-1 2 4 6-1 3 Index 4 6-1 4 4 6-1 4 xxv 4 6-1 5 4 6-1 5 4 6-1 6 4 6- 17 4 6-1 8 4 6-1 9 4 6-2 1 4 6-2 2 4 6-2 3 4 6-2 3 4 6-2 4 4 6-2 5 4 6-2 5 4 6-2 6 4 6- 27 I-1 Tables 1.1 3.1 3.2 5.1 5.2 5.3 5.4 5.5 5.6 5 .7 5.8 5.9 5.10 5.11 5.12... object Fine-tuning a connection Forcing asynchronous connections Controlling time-outs 2 7- 7 2 7- 7 2 7- 8 2 7- 8 2 7- 8 2 7- 9 2 7- 9 2 7- 9 2 7- 10 2 7- 11 2 7- 11 2 7- 12 2 7- 13 2 7- 15 2 7- 16 2 7- 18 2 7- 18 2 7- 19 2 7- 19 2 7- 20 2 7- 20 Chapter 28 Using unidirectional datasets Types of unidirectional datasets Connecting to the... with Delphi Requirements for COM interoperability NET components and type libraries Accessing user-defined NET components 4 1-2 1 4 1-2 1 4 1-2 2 4 1-2 3 4 1-2 3 4 1-2 4 4 1-2 4 4 1-2 4 4 1-2 5 4 1-2 5 4 1-2 6 4 1-2 6 4 1-2 6 4 1- 27 4 1- 27 4 1- 27 xxiii 4 2-1 4 2-2 4 2-3 4 2-4 4 2-5 4 2-6 4 2-6 4 2-6 42 -7 4 2-8 4 2-9 4 2-1 0 4 2-1 0 4 2-1 1 4 2-1 2... 2 0-1 0 2 0-2 2 2 0-2 2 2 0-2 4 2 0-2 6 2 0-2 6 2 0- 27 2 0-2 8 2 0-2 9 2 0-3 0 2 0-3 0 2 0-3 1 2 0-3 1 2 0-3 2 Chapter 21 Creating reports with Rave Reports 2 1-1 Overview 2 1-1 Getting started 2 1-2 The Rave Visual Designer 2 1-3 xii 2 2-1 2 2-1 2 2-2 2 2-3 2 2-3 2 2-4 2 2-5 2 2-6 2 2-6 22 -7 22 -7 2 2-8 2 2-8 2 2-9 2 2-9 2 2-9 ... password-protected Paradox and dBASE tables Specifying Paradox directory locations Working with BDE aliases Retrieving information about a session 2 5- 17 2 5-1 8 2 5-1 8 2 5-1 9 2 5-2 0 2 5-2 1 2 5-2 1 2 5-2 2 2 5-2 2 2 5-2 2 2 5-2 3 2 5-2 3 2 5-2 4 2 5-2 5 2 5-2 5 2 5-2 5 2 5-2 5 2 5-2 6 2 5-2 6 2 5-2 6 2 5-2 6 2 5- 27 2 5- 27 2 5- 27 2 5- 27 2 5-2 8 2 5-2 8 2 5-2 8 2 5-2 9 xv 2 6-1 2 6-2 . string list . . . . . . 7- 14 Drawing owner-drawn items . . . . . . 7- 15 Sizing owner-draw items. . . . . . . . . . . 7- 16 Drawing owner-draw items . . . . . . . . . 7- 17 Chapter 8 Building applications,. . . . . . . . . . 7- 6 Setting text alignment . . . . . . . . . . . . . 7- 7 Adding scroll bars at runtime. . . . . . . . . 7- 7 Adding the clipboard object. . . . . . . . . . 7- 8 Selecting text. 6-9 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

Ngày đăng: 16/04/2014, 11:16

TỪ KHÓA LIÊN QUAN