Developer’s Guide Borland Delphi 7 for Windows PHẦN 1 pptx

112 508 0
Developer’s Guide Borland Delphi 7 for Windows PHẦN 1 pptx

Đ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

Developer’s Guide Borland Software Corporation 100 Enterprise Way, Scotts Valley, CA 95066-3249 www.borland.com Borland ® Delphi ™ 7 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 [...]... Distributing a client application as an ActiveX control Creating an Active Form for the client application xviii 31- 11 31- 12 31- 13 31- 13 31- 15 31- 16 31- 16 31- 17 31- 17 31- 17 31- 18 31- 19 31- 21 31- 22 31- 22 31- 23 31- 24 31- 24 31- 25 31- 26 31- 27 31- 27 31- 27 31- 28 31- 28 31- 29 31- 29 31- 30 31- 30 31- 31 31- 32 31- 33 Building Web applications using InternetExpress Building an InternetExpress... image control 18 -12 18 -13 18 -14 18 -14 18 -15 18 -15 18 -15 18 -16 18 -16 18 -16 Part II Developing database applications Chapter 19 Designing database applications 19 -5 19 -6 19 -6 19 -6 19 -6 19 -8 19 -9 19 -10 19 -12 19 -13 19 -14 19 -15 19 -15 19 -16 Chapter 20 18 -12 18 -12 19 -4 19 -1 Using databases 19 -1 Types of databases 19 -2 Database security... synchronization options 46.4 Event publisher return codes xxviii 44-6 44-6 46 -12 46- 17 46 -19 46-23 Figures 3 .1 4 .1 9 .1 9.3 9.4 9.6 9 .7 10 .2 11 .1 11. 2 11 .3 11 .4 11 .5 11 .6 11 .7 11 .8 11 .9 12 .1 17 . 1 17 . 2 17 . 3 17 . 4 19 .1 19.2 19 .3 19 .4 19 .5 20 .1 20.2 20.3 20.4 A simplified hierarchy diagram A simple form A frame with data-aware controls and a data source component Menu... xxvi 10 -2 12 -3 12 -4 12 -4 12 -22 12 -24 12 -25 12 -33 13 -3 13 -11 14 -10 15 -2 15 -7 15 -8 15 -9 15 -9 15 -18 15 -20 15 -23 15 - 27 16 -2 16 -11 16 -13 17 - 3 17 - 6 17 - 7 18 -3 18 -4 18 -7 18 -8 20-2 20-20 20- 21 20.4 Properties that affect the way composite fields appear 20.5 Expanded TDBGrid Options properties 20.6 Grid control events 20 .7 Selected database control... 34 -10 34 -10 34 -11 34 -11 34 -11 34 -11 34 -12 34 -12 34 -12 34 -12 34 -13 34 -13 34 -13 34 -14 34 -14 34 -15 34 -16 34 -16 34- 17 34 -18 34 -18 xx 35 -1 35-2 35-2 35-3 35-4 35-5 35-5 35-6 35-6 35-6 35-6 35-6 35 -7 35-8 35-9 35 -10 35 -11 35 -12 35 -13 35 -13 35 -14 35 -15 35- 17 35- 17 35 -18 35 -18 35 -19 Server-side... to True 3-5 4-3 9 -16 9-32 9-33 9-36 9- 37 10 -15 11 -3 11 -4 11 -5 11 -5 11 -6 11 -7 11 -8 11 -8 11 -9 12 - 21 17 - 5 17 - 5 17 - 5 17 - 5 19 -6 19 -8 19 -9 19 -12 19 -13 20 -15 20-23 20-23 20.5 TDBCtrlGrid at design time 20.6 Buttons on the TDBNavigator control 22 .1 Decision support components at design time... 20-24 20-25 20- 27 27. 1 27. 2 27. 3 27. 4 27. 5 20-29 20-30 21- 6 23 -1 24-3 24-5 24-6 28 .1 28.2 28.3 28.4 24 -14 24 -16 24 -16 28.5 29 .1 29.2 24- 17 29.3 24-22 24-28 25 -1 25-6 25 -11 25 -15 25 -16 25- 17 25-20 25-24 30 .1 30.2 30.3 30.4 30.5 31. 1 26-5 26-6 26-8 31. 2 31. 3 33 .1 34 .1 34.2 35 .1 35.2 35.3 35.4 35.5 26- 27 36 .1 26-30 38 .1 40 .1 40.2 25-24 ... 46 -1 46-2 46-3 46-3 46-4 46-4 46-5 46-6 46-6 46-8 46-8 46-9 46 -10 46 -11 46 -11 46 -12 46 -12 46 -13 Index 46 -14 46 -14 xxv 46 -15 46 -15 46 -16 46- 17 46 -18 46 -19 46- 21 46-22 46-23 46-23 46-24 46-25 46-25 46-26 46- 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 5 .13 5 .14 5 .15 5 .16 ... library information Apply Updates dialog Saving a type library Refreshing the type library Registering the type library Exporting an IDL file Deploying type libraries 41- 1 Creating COM clients 41- 2 41- 3 41- 3 41- 5 41- 5 41- 6 41- 8 41- 9 41- 9 41- 10 41- 10 41- 11 41- 11 41- 12 41- 13 41- 19 41- 20 Importing type library information... Fine-tuning a connection Forcing asynchronous connections Controlling time-outs 27- 7 27- 7 27- 8 27- 8 27- 8 27- 9 27- 9 27- 9 27- 10 27- 11 27- 11 27- 12 27- 13 27- 15 27- 16 27- 18 27- 18 27- 19 27- 19 27- 20 27- 20 Chapter 28 Using unidirectional datasets Types of unidirectional datasets Connecting to the database . . . . . . 17 - 10 Dynamic switching of resource DLLs. . . 17 - 11 Localizing applications. . . . . . . . . . . . . 17 - 12 Localizing resources. . . . . . . . . . . . . 17 - 12 xi Chapter 18 Deploying. U.S.A. HDE1 370 WW 210 01 7E5R0802 0203040506-9 8 76 543 21 D3 iii Chapter 1 Introduction 1- 1 What’s in this manual? . . . . . . . . . . . . . . 1- 1 Manual conventions . . . . . . . . . . . . . . . . 1- 2 Developer. . . . . . . . . . 17 - 7 Designing the user interface . . . . . . . . . 17 - 7 Text . . . . . . . . . . . . . . . . . . . . . 17 - 7 Graphic images . . . . . . . . . . . . . . 17 - 8 Formats and sort

Ngày đăng: 12/08/2014, 09:21

Từ khóa liên quan

Mục lục

  • Developer’s Guide

    • Contents

    • Tables

    • Figures

    • Ch 1: Introduction

      • What’s in this manual?

      • Manual conventions

      • Developer support services

      • Part I: Programming with Delphi

      • Ch 2: Developing applications with Delphi

        • Integrated development environment

        • Designing applications

        • Creating projects

        • Editing code

        • Compiling applications

        • Debugging applications

        • Deploying applications

        • Ch 3: Using the component library

          • Understanding the component library

            • Properties, methods, and events

              • Properties

              • Methods

              • Events

              • User events

              • System events

              • Internal events

Tài liệu cùng người dùng

Tài liệu liên quan