Developer’s Guide - Embarcadero Website

[Pages:1106]Developer's Guide

Borland?

DelphiTM 7

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 Delphi 7 product for a complete list of files that you can distribute in accordance with the Delphi 7 License Statement and Limited Warranty.

Borland Software Corporation may have patents and/or pending patent applications covering subject matter in this document. Please refer to the product CD or the About dialog box for the list of applicable patents. The furnishing of this document does not give you any license to these patents.

COPYRIGHT ? 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 7 6 5 4 3 2 1 D3

Contents

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

iii

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

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

iv

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

Service name properties. . . . . . . . . . . 8-9

Debugging service applications . . . . . . 8-9

Creating packages and DLLs . . . . . . . . . . 8-10

When to use packages and DLLs . . . . . . 8-11

Writing database applications . . . . . . . . . . 8-11

Distributing database applications . . . . . 8-12

Creating Web server applications . . . . . . . . 8-12

Creating Web Broker applications . . . . . . 8-13

Creating WebSnap applications . . . . . . . 8-14

Creating Web Services applications . . . . . 8-14

Writing applications using COM . . . . . . . . 8-15

Using COM and DCOM . . . . . . . . . . . 8-15

Using MTS and COM+ . . . . . . . . . . . . 8-15

Using data modules . . . . . . . . . . . . . . . 8-16

Creating and editing standard

data modules. . . . . . . . . . . . . . . . . 8-16

Naming a data module and its

unit file . . . . . . . . . . . . . . . . . . 8-17

Placing and naming components . . . . 8-18

Using component properties and

events in a data module . . . . . . . . . 8-18

Creating business rules in a data

module . . . . . . . . . . . . . . . . . . 8-19

Accessing a data module from a form . . . 8-19

Adding a remote data module to an

application server project . . . . . . . . . . 8-20

v

Using the Object Repository . . . . . . . . . . . 8-20 Sharing items within a project . . . . . . . . 8-20 Adding items to the Object Repository . . . 8-21 Sharing objects in a team environment . . . 8-21 Using an Object Repository item in a project . . . . . . . . . . . . . . . . . . . 8-21 Copying an item . . . . . . . . . . . . . . 8-21 Inheriting an item. . . . . . . . . . . . . . 8-22 Using an item . . . . . . . . . . . . . . . . 8-22 Using project templates . . . . . . . . . . . . 8-22 Modifying shared items . . . . . . . . . . . . 8-22 Specifying a default project, new form, and main form . . . . . . . . . . . . . . . . 8-23

Enabling Help in applications . . . . . . . . . . 8-23 Help system interfaces . . . . . . . . . . . . . 8-24 Implementing ICustomHelpViewer . . . . . 8-24 Communicating with the Help Manager . . . . . . . . . . . . . . . . . . . . 8-25 Asking the Help Manager for information . . . . . . . . . . . . . . . . . . 8-25 Displaying keyword-based Help . . . . . . . 8-26 Displaying tables of contents . . . . . . . . . 8-27 Implementing IExtendedHelpViewer . . . . 8-27 Implementing IHelpSelector . . . . . . . . . 8-28 Registering Help system objects . . . . . . . 8-29 Registering Help viewers . . . . . . . . . 8-29 Registering Help selectors . . . . . . . . . 8-29

Using Help in a VCL application. . . . . . . . . 8-30 How TApplication processes VCL Help . . . 8-30 How VCL controls process Help . . . . . . . 8-30

Using Help in a CLX application. . . . . . . . . 8-31 How TApplication processes CLX Help . . . 8-31 How CLX controls process Help . . . . . . . 8-31

Calling a Help system directly . . . . . . . . . . 8-32 Using IHelpSystem . . . . . . . . . . . . . . . . 8-32 Customizing the IDE Help system . . . . . . . . 8-33

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

vi

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

Edit control properties . . . . . . . . . . 10-2

Memo and rich edit controls . . . . . . . 10-3

Text viewing controls . . . . . . . . . . . . . 10-3

Labels . . . . . . . . . . . . . . . . . . . . . . 10-4

Specialized input controls . . . . . . . . . . . . 10-5

Scroll bars . . . . . . . . . . . . . . . . . . . 10-5

Track bars. . . . . . . . . . . . . . . . . . . . 10-5

Up-down controls . . . . . . . . . . . . . . . 10-6

Spin edit controls (CLX only) . . . . . . . . 10-6

Hot key controls (VCL only) . . . . . . . . . 10-6

Splitter controls . . . . . . . . . . . . . . . . 10-7

Buttons and similar controls . . . . . . . . . . . 10-7

Button controls. . . . . . . . . . . . . . . . . 10-8

Bitmap buttons . . . . . . . . . . . . . . . . 10-8

Speed buttons . . . . . . . . . . . . . . . . . 10-8

Check boxes . . . . . . . . . . . . . . . . . . 10-9

Radio buttons . . . . . . . . . . . . . . . . . 10-9

Toolbars. . . . . . . . . . . . . . . . . . . . . 10-9

Cool bars (VCL only) . . . . . . . . . . . . 10-10

List controls . . . . . . . . . . . . . . . . . . . 10-10

List boxes and check-list boxes . . . . . . .10-11

Combo boxes. . . . . . . . . . . . . . . . . .10-11

Tree views . . . . . . . . . . . . . . . . . . 10-12

vii

List views . . . . . . . . . . . . . . . . . . . 10-13 Icon views (CLX only) . . . . . . . . . . . . 10-13 Date-time pickers and month

calendars. . . . . . . . . . . . . . . . . . . 10-13 Grouping controls . . . . . . . . . . . . . . . . 10-13

Group boxes and radio groups . . . . . . . 10-14 Panels . . . . . . . . . . . . . . . . . . . . . 10-14 Scroll boxes . . . . . . . . . . . . . . . . . . 10-14 Tab controls . . . . . . . . . . . . . . . . . . 10-15 Page controls . . . . . . . . . . . . . . . . . 10-15 Header controls. . . . . . . . . . . . . . . . 10-15 Display controls . . . . . . . . . . . . . . . . . 10-16 Status bars. . . . . . . . . . . . . . . . . . . 10-16 Progress bars . . . . . . . . . . . . . . . . . 10-16 Help and hint properties . . . . . . . . . . 10-17 Grids. . . . . . . . . . . . . . . . . . . . . . . . 10-17 Draw grids . . . . . . . . . . . . . . . . . . 10-17 String grids . . . . . . . . . . . . . . . . . . 10-17 Value list editors (VCL only) . . . . . . . . . . 10-18 Graphic controls . . . . . . . . . . . . . . . . . 10-19 Images . . . . . . . . . . . . . . . . . . . . . 10-19 Shapes . . . . . . . . . . . . . . . . . . . . . 10-19 Bevels . . . . . . . . . . . . . . . . . . . . . 10-19 Paint boxes . . . . . . . . . . . . . . . . . . 10-20 Animation control . . . . . . . . . . . . . . 10-20

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

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

viii

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

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download