Tải bản đầy đủ (.pdf) (638 trang)

delphi - borland kylix for linux developer's guide

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (8.04 MB, 638 trang )

Developer’s Guide
Borland Software Corporation
100 Enterprise Way, Scotts Valley, CA 95066-3249
Borland
®
Kylix

Delphi

for Linux
®
Refer to the file DEPLOY located in the root directory of your Kylix product for a complete list of files that you can
distribute in accordance with the Kylix License Statement and Limited Warranty.
Borland Software Corporation may have patents and/or pending patent applications covering subject matter in this
document. The furnishing of this document does not give you any license to these patents.
C
OPYRIGHT
© 1983, 2001 Borland Software Corporation. All rights reserved. All Inprise and Borland brand and
product names are trademarks or registered trademarks of Borland Software Corporation. Other brand and product
names are trademarks or registered trademarks of their respective holders.
PrintedintheU.S.A.
HDB7010WW21001 1E0R0201
0102030405-9 8 7654321
PDF
iii
Chapter 1
Introduction 1-1
What’sinthismanual? 1-1
Manualconventions 1-2
Developersupportservices 1-2
Orderingprinteddocumentation 1-2


Part I
Programming with Kylix
Chapter 2
Developing applications with Kylix 2-1
Integrateddevelopmentenvironment 2-1
Designingapplications 2-2
Developingapplications 2-2
Creatingprojects 2-3
Editing code. . . 2-3
Compiling applications . . 2-4
Debuggingapplications 2-4
Deployingapplications 2-5
Chapter 3
Using CLX 3-1
UnderstandingCLX 3-1
Properties,methods,andevents 3-3
Properties 3-3
Methods 3-4
Events 3-4
Widgetevents 3-4
Systemevents 3-4
Whatisanobject? 3-5
ExaminingaKylixobject 3-5
Changing the name of a component . . . 3-7
Inheriting data and code from an object . . . 3-8
Scopeandqualifiers 3-8
Private, protected, public, and published
declarations 3-9
Usingobjectvariables 3-10
Creating, instantiating, and destroying

objects 3-11
Componentsandownership 3-11
MajorbranchesoftheCLXhierarchy 3-12
TObjectbranch 3-13
TPersistentbranch 3-14
TComponentbranch 3-14
TControlbranch 3-16
TWidgetControlbranch 3-17
Usingcomponents 3-17
Components on the component palette. . . 3-18
Textcontrols 3-19
Textcontrolproperties 3-19
Propertiesofmemocontrols 3-20
Specializedinputcontrols 3-20
Scrollbars 3-20
Trackbars 3-20
Spin edit controls 3-21
Buttonsandsimilarcontrols 3-21
Buttoncontrols 3-22
Bitmapbuttons 3-22
Speedbuttons 3-22
Checkboxes 3-22
Radiobuttons 3-23
Toolbars 3-23
Splittercontrols 3-23
Handlinglists 3-24
Listboxesandcheck-listboxes 3-24
Comboboxes 3-25
Treeviews 3-25
Listviews 3-25

Groupingcomponents 3-26
Groupboxesandradiogroups 3-26
Panels 3-26
Scrollboxes 3-27
Tabcontrols 3-27
Pagecontrols 3-27
Headercontrols 3-27
Providingvisualfeedback 3-28
Labels 3-28
Statusbars 3-28
Progressbars 3-29
Helpandhintproperties 3-29
Grids 3-29
Drawgrids 3-29
Stringgrids 3-30
Graphicsdisplay 3-30
Images 3-30
Shapes 3-30
Bevels 3-31
Paintboxes 3-31
Dialogboxes 3-31
Usingopendialogboxes 3-31
Usinghelperobjects 3-32
Workingwithlists 3-32
Contents
iv
Workingwithstringlists 3-32
Loadingandsavingstringlists 3-33
Creatinganewstringlist 3-33
Manipulatingstringsinalist 3-35

Associating objects with a string list . . .3-37
Creatingdrawingspaces 3-37
Printing 3-38
Usingstreams 3-38
Chapter 4
Common programming tasks 4-1
Understandingclasses 4-1
Definingclasses 4-2
Handlingexceptions 4-4
Protectingblocksofcode 4-4
Respondingtoexceptions 4-5
Exceptionsandtheflowofcontrol 4-5
Nestingexceptionresponses 4-6
Protectingresourceallocations 4-7
What kind of resources need
protection? 4-7
Creating a resource protection block . . . 4-8
HandlingRTLexceptions 4-8
WhatareRTLexceptions? 4-9
Creatinganexceptionhandler 4-10
Exceptionhandlingstatements 4-10
Usingtheexceptioninstance 4-11
Scopeofexceptionhandlers 4-12
Providing default exception
handlers 4-12
Handlingclassesofexceptions 4-13
Reraisingtheexception 4-13
Handlingcomponentexceptions 4-14
Exception handling with external
sources 4-14

Silentexceptions 4-15
Definingyourownexceptions 4-16
Declaringanexceptionobjecttype 4-16
Raisinganexception 4-16
Usinginterfaces 4-17
Interfacesasalanguagefeature 4-17
Implementing interfaces across
thehierarchy 4-18
Usinginterfaceswithprocedures 4-19
ImplementingIInterface 4-20
TInterfacedObject 4-20
Usingtheasoperator 4-21
Reusingcodeanddelegation 4-22
Usingimplementsfordelegation 4-22
Memory management of interface
objects 4-23
Usingreferencecounting 4-23
Notusingreferencecounting 4-24
Workingwithstrings 4-24
Charactertypes 4-25
Stringtypes 4-25
Shortstrings 4-26
Longstrings 4-26
WideString 4-27
PChartypes 4-27
OpenString 4-27
Runtime library string handling
routines 4-27
Widecharacterroutines 4-28
Commonly used long string

routines 4-28
Declaringandinitializingstrings 4-31
Mixingandconvertingstringtypes 4-32
StringtoPCharconversions 4-32
Stringdependencies 4-32
Returning a PChar local variable. . . . . 4-33
Passing a local variable as a PChar . . . 4-33
Compilerdirectivesforstrings 4-34
Strings and characters: related topics . . . . 4-34
Workingwithfiles 4-35
Manipulatingfiles 4-35
Deletingafile 4-35
Findingafile 4-36
Changingfileattributes 4-37
Renamingafile 4-38
Filedate-timeroutines 4-38
FiletypeswithfileI/O 4-38
Usingfilestreams 4-39
Creatingandopeningfiles 4-39
Usingthefilehandle 4-40
Readingandwritingtofiles 4-40
Readingandwritingstrings 4-41
Seekingafile 4-41
Filepositionandsize 4-42
Copying 4-42
ObjectPascaldatatypes 4-43
Chapter 5
Building applications and shared objects
5-1
Creatingapplications 5-1

GUIapplications 5-1
Userinterfacemodels 5-2
v
Setting IDE, project, and compilation
options 5-2
Consoleapplications 5-2
Creatingpackagesandsharedobjectfiles 5-3
Workingwithsharedobjectlibraries 5-3
When to use packages and shared
objects 5-4
Writingdatabaseapplications 5-4
Building distributed applications . . . 5-5
Distributing applications using TCP/IP . . . 5-5
Usingsocketsinapplications 5-5
CreatingWebserverapplications 5-6
Using data modules and remote data
modules 5-6
Creatingdatamodules 5-7
Creating business rules in a data
module 5-7
Accessingadatamodulefromaform 5-7
Programmingtemplates 5-8
Sharing code: Using the Object Repository . . . 5-8
Sharingitemswithinaproject 5-8
Adding items to the Object Repository . . . 5-8
Sharing objects in a team environment . . . 5-9
Using an Object Repository item in a
project 5-9
Copyinganitem 5-9
Inheritinganitem 5-10

Usinganitem 5-10
Usingprojecttemplates 5-10
Modifyingshareditems 5-10
Specifying a default project, new form,
andmainform 5-11
Reusing components and groups of
components 5-11
Creating and using component templates . . . 5-11
EnablingHelpinCLXapplications 5-12
Helpsysteminterfaces 5-12
ImplementingICustomHelpViewer 5-13
Communicating with the Help
Manager 5-13
Asking the Help Manager for
information 5-14
Displayingkeyword-basedHelp 5-15
Displayingtablesofcontents 5-15
ImplementingIExtendedHelpViewer 5-16
ImplementingIHelpSelector 5-17
RegisteringHelpsystemobjects 5-17
RegisteringHelpviewers 5-17
RegisteringHelpselectors 5-18
UsingHelpinaCLXApplication 5-18
How TApplication processes Help . . . . . 5-18
HowcontrolsprocessHelp 5-18
CallingtheHelpsystemdirectly 5-19
UsingIHelpSystem 5-19
CustomizingtheIDEHelpsystem 5-20
Chapter 6
Developing the application

user interface 6-1
Controlling application behavior 6-1
Usingthemainform 6-1
Addingforms 6-2
Linkingforms 6-2
Hidingthemainform 6-3
Workingattheapplicationlevel 6-3
Setting up the look and feel of your
application 6-3
Handlingthescreen 6-4
Managinglayout 6-4
Usingforms 6-4
Controlling when forms reside in
memory 6-5
Displayinganauto-createdform 6-5
Creatingformsdynamically 6-5
Creating modeless forms such as
windows 6-6
Using a local variable to create a form
instance 6-6
Passing additional arguments to forms . . . . 6-7
Retrievingdatafromforms 6-8
Retrieving data from modeless forms . . . 6-8
Retrieving data from modal forms. . . . . 6-9
Workingwithframes 6-11
Creatingframes 6-11
Adding frames to the Component
palette 6-12
Usingandmodifyingframes 6-12
Sharingframes 6-13

Usingactionlists 6-13
Whatisanaction? 6-14
Settingupactionlists 6-14
What happens when an action fires . . . . . 6-15
Respondingwithevents 6-15
Howactionsfindtheirtargets 6-17
Updatingactions 6-17
Predefinedactionclasses 6-18
Writingactioncomponents 6-18
Registeringactions 6-19
vi
Creatingandmanagingmenus 6-19
Designingmenus 6-20
Building menus. 6-22
Namingmenus 6-22
Namingthemenuitems 6-22
Adding, inserting, and deleting
menuitems 6-23
Creatingsubmenus 6-24
Addingimagestomenuitems 6-26
Viewingthemenu 6-26
Editing menu items in the Object
Inspector 6-27
Using the Menu Designer context
menu 6-27
Commandsonthecontextmenu 6-27
Switching between menus at
designtime 6-28
Usingmenutemplates 6-29
Savingamenuasatemplate 6-30

Naming conventions for template menu
itemsandeventhandlers 6-31
Manipulatingmenuitemsatruntime 6-31
Designingtoolbars 6-31
Adding a toolbar using a panel
component 6-32
Addingaspeedbuttontoapanel 6-32
Assigningaspeedbutton’sglyph 6-33
Setting the initial condition of a
speedbutton 6-33
Creatingagroupofspeedbuttons 6-33
Allowingtogglebuttons 6-34
Adding a toolbar using the toolbar
component 6-34
Addingatoolbutton 6-34
Assigningimagestotoolbuttons 6-35
Setting tool button appearance and
initialconditions 6-35
Creatinggroupsoftoolbuttons 6-35
Allowingtoggledtoolbuttons 6-36
Respondingtoclicks 6-36
Assigningamenutoatoolbutton 6-36
Adding hidden toolbars . . 6-36
Hidingandshowingtoolbars 6-37
Chapter 7
Working with controls 7-1
Workingwithtextincontrols 7-1
Settingtextalignment 7-1
Addingscrollbarsatruntime 7-2
Addingaclipboardtoanapplication 7-3

Selectingtext 7-3
Selectingalltext 7-4
Cutting,copying,andpastingtext 7-4
Deletingselectedtext 7-5
Disablingmenuitems 7-5
Providingapop-upmenu 7-5
HandlingtheOnPopupevent 7-6
Addinggraphicstocontrols 7-7
Indicating that a control is owner-drawn. . . 7-7
Adding graphical objects to a string list . . . 7-8
Adding images to an application . . . . . 7-8
Sizingowner-drawitems 7-8
Drawingowner-drawitems 7-9
Chapter 8
Working with graphics 8-1
Overviewofgraphicsprogramming 8-1
Refreshingthescreen 8-2
Typesofgraphicobjects 8-2
Common properties and methods of
Canvas 8-3
Using the properties of the Canvas
object 8-5
Usingpens 8-5
Usingbrushes 8-7
Changingthebrushcolor 8-7
Changingthebrushstyle 8-8
Setting the Brush Bitmap property. . . . . 8-8
Using Canvas methods to draw graphic
objects 8-9
Drawinglinesandpolylines 8-9

Drawingshapes 8-10
Handling multiple drawing objects in your
application 8-11
Keeping track of which drawing tool
touse 8-11
Changing the tool with speed buttons . . . 8-12
Usingdrawingtools 8-13
Drawingshapes 8-13
Sharing code among event
handlers 8-14
Drawingonagraphic 8-16
Makingscrollablegraphics 8-16
Addinganimagecontrol 8-16
Placingthecontrol 8-16
Settingtheinitialbitmapsize 8-17
Drawingonthebitmap 8-17
Loadingandsavinggraphicsfiles 8-18
Loadingapicturefromafile 8-18
Savingapicturetoafile 8-19
vii
Replacingthepicture 8-19
Usingtheclipboardwithgraphics 8-20
Copyinggraphicstotheclipboard 8-21
Cuttinggraphicstotheclipboard 8-21
Pastinggraphicsfromtheclipboard 8-21
Rubberbandingexample 8-22
Respondingtothemouse 8-22
What’sinamouseevent? 8-23
Responding to a mouse-down action. . .8-23
Respondingtoamouse-upaction 8-24

Respondingtoamousemove 8-24
Adding a field to a form object to track
mouseactions 8-25
Refininglinedrawing 8-26
Trackingtheoriginpoint 8-26
Trackingmovement 8-27
Chapter 9
Writing multi-threaded
applications 9-1
Definingthreadobjects 9-1
Initializingthethread 9-2
Assigningadefaultpriority 9-2
Indicatingwhenthreadsarefreed 9-3
Writingthethreadfunction 9-3
UsingthemainCLXthread 9-3
Usingthread-localvariables 9-5
Checking for termination by other
threads 9-5
Handling exceptions in the thread
function 9-5
Writingclean-upcode 9-6
Coordinatingthreads 9-6
Avoiding simultaneous access . . . 9-6
Lockingobjects 9-6
Usingcriticalsections 9-7
Using the multi-read exclusive-write
synchronizer 9-7
Other techniques for sharing
memory 9-8
Waitingforotherthreads 9-8

Waiting for a thread to finish
executing 9-8
Waitingforatasktobecompleted 9-9
Executingthreadobjects 9-10
Overridingthedefaultpriority 9-10
Startingandstoppingthreads 9-11
Debuggingmulti-threadedapplications 9-11
Chapter 10
Developing cross-platform
applications 10-1
Porting Windows applications to Linux . . . . 10-1
Portingtechniques 10-2
Platform-specificports 10-2
Cross-platformports 10-2
Windowsemulationports 10-2
Portingyourapplication 10-2
CLXversusVCL 10-4
WhatCLXdoesdifferently 10-5
Lookandfeel 10-5
Styles 10-5
Variants 10-5
Noregistry 10-6
Otherdifferences 10-6
MissinginCLX 10-6
Featuresthatwillnotport 10-7
KylixandDelphiunitcomparison 10-8
Differences in CLX object
constructors 10-11
Sharing source files between Windows
andLinux 10-12

Environmental differences between
WindowsandLinux 10-12
DirectorystructureonLinux 10-14
Writingportablecode 10-15
Usingconditionaldirectives 10-16
Terminating conditional
directives 10-17
Emittingmessages 10-18
Including inline assembler code . . . . 10-18
Messagesandsystemevents 10-19
Programming differences on Linux . . . . 10-20
Cross-platform database applications . . . . 10-21
dbExpressdifferences 10-21
Component-leveldifferences 10-22
Userinterface-leveldifferences 10-23
Porting database applications to
Linux 10-23
Updating data in dbExpress
applications 10-25
Cross-platformInternetapplications 10-27
Porting Internet applications to
Linux 10-27
viii
Chapter 11
Working with packages and
components 11-1
Whyusepackages? 11-2
Packagesandstandardsharedobject
files 11-2
Runtimepackages 11-2

Usingpackagesinanapplication 11-3
Dynamicallyloadingpackages 11-4
Deciding which runtime packages
touse 11-4
Custompackages 11-4
Design-timepackages 11-4
Installingcomponentpackages 11-5
Creatingandeditingpackages 11-6
Creatingapackage 11-6
Editing an existing package 11-7
Editing package source files manually 11-7
Understanding the structure of a
package 11-8
Namingpackages 11-8
TheRequiresclause 11-8
TheContainsclause 11-9
Compiling packages 11-9
Package-specific compiler
directives 11-10
Using the command-line compiler
andlinker 11-11
Package files created by a successful
compilation 11-11
Deployingpackages 11-12
Deploying applications that use
packages 11-12
Distributing packages to other
developers 11-12
Chapter 12
Creating international

applications 12-1
Internationalizationandlocalization 12-1
Internationalization 12-1
Localization 12-1
Internationalizingapplications 12-2
Enablingapplicationcode 12-2
Charactersets 12-2
Multiplebytecharactersets 12-2
Widecharacters 12-3
Designingtheuserinterface 12-4
Text 12-4
Graphicimages 12-4
Formatsandsortorder 12-4
Keyboardmappings 12-5
Isolatingresources 12-5
Creatingresourcemodules 12-5
Usingresourcemodules 12-6
Localizingapplications 12-6
Chapter 13
Deploying applications 13-1
Deployinggeneralapplications 13-1
Deploymentissues 13-2
Usinginstallationprograms 13-2
Identifyingapplicationfiles 13-2
Packagefiles 13-2
Helperapplications 13-3
Sharedobjectfilelocations 13-3
Deployingdatabaseapplications 13-3
Connectingtoadatabase 13-4
Updatingconfigurationfiles 13-4

DeployingWebapplications 13-4
DeploymentonApache 13-5
Programming for varying host
environments 13-5
Screen resolutions and color depths. . . . . 13-6
Considerations when not dynamically
resizing 13-6
Considerations when dynamically
resizingformsandcontrols 13-6
Accommodating varying color
depths 13-7
Fonts 13-8
Softwarelicenserequirements 13-8
Deploy.txt 13-8
README 13-8
No-nonsenselicenseagreement 13-9
GPLlicenseagreement 13-9
Third-party product documentation . . . . 13-9
Part II
Developing database applications
Chapter 14
Designing database applications 14-1
Usingdatabases 14-1
Typesofdatabases 14-2
Databasesecurity 14-3
ix
Transactions 14-3
Referential integrity, stored procedures,
andtriggers 14-4
Databasearchitecture 14-4

Generalstructure 14-4
Theuserinterfaceform 14-5
Thedatamodule 14-5
Using a client dataset with data stored
ondisk 14-6
Usingaunidirectionaldatasetdirectly 14-8
Using a client dataset to buffer
records 14-9
Usingamulti-tieredarchitecture 14-11
Combiningapproaches 14-12
Chapter 15
Using data controls 15-1
Usingcommondatacontrolfeatures 15-2
Associating a data control with a
dataset 15-3
Changing the associated dataset
atruntime 15-3
Enabling and disabling the data
source 15-4
Responding to changes mediated by
thedatasource 15-4
Editing and updating data 15-4
Enabling editing in controls on
userentry 15-5
Editing data in a control 15-5
Disablingandenablingdatadisplay 15-6
Refreshingdatadisplay 15-6
Enabling mouse, keyboard, and
timerevents 15-7
Choosinghowtoorganizethedata 15-7

Displayingasinglerecord 15-7
Displayingdataaslabels 15-7
Displaying and editing fields in
aneditbox 15-8
Displaying and editing text in a
memocontrol 15-8
Displaying and editing graphics fields
inanimagecontrol 15-9
Displaying and editing data in list and
comboboxes 15-9
Handling Boolean field values with
checkboxes 15-12
Restricting field values with radio
controls 15-12
Displayingmultiplerecords 15-13
Viewing and editing data with
TDBGrid 15-14
Using a grid control in its default
state 15-15
Creatingacustomizedgrid 15-15
Understanding persistent
columns 15-16
Creatingpersistentcolumns 15-16
Deletingpersistentcolumns 15-17
Arranging the order of persistent
columns 15-18
Setting column properties at design
time 15-18
Definingalookuplistcolumn 15-19
Puttingabuttoninacolumn 15-20

Restoring default values to a
column 15-20
Displayingcompositefields 15-21
Settinggridoptions 15-22
Editing in the grid . 15-23
Controlling grid drawing. . . 15-23
Responding to user actions at
runtime 15-24
Navigating and manipulating records . . . . 15-25
Choosing navigator buttons to
display 15-26
Hiding and showing navigator
buttonsatdesigntime 15-26
Hiding and showing navigator
buttonsatruntime 15-26
Displayingfly-overhelp 15-27
Using a single navigator for multiple
datasets 15-27
Chapter 16
Understanding datasets 16-1
Typesofdatasets 16-2
Openingandclosingdatasets 16-2
Determiningandsettingdatasetstates 16-3
Inactivatingadataset 16-4
Browsingadataset 16-5
Enablingdatasetediting 16-6
Enablinginsertionofnewrecords 16-7
Enablingindex-basedoperations 16-7
Calculatingfields 16-8
Filteringrecords 16-8

Applyingupdates 16-8
Navigatingdatasets 16-8
x
UsingtheFirstandLastmethods 16-9
UsingtheNextandPriormethods 16-10
UsingtheMoveBymethod 16-10
UsingtheEofandBofproperties 16-10
Eof 16-11
Bof 16-11
Markingandreturningtorecords 16-12
Searchingdatasets 16-14
UsingLocate 16-14
UsingLookup 16-15
Displaying and editing a subset of data
usingfilters 16-15
Enablinganddisablingfiltering 16-16
Creatingfilters 16-16
Settingfilteroptions 16-19
Navigating records in a filtered
dataset 16-20
Modifyingdata 16-20
Editing records . 16-21
Addingnewrecords 16-22
Insertingrecords 16-22
Appendingrecords 16-23
Deletingrecords 16-23
Postingdatatothedatabase 16-23
Cancelingchanges 16-24
Modifyingentirerecords 16-24
Usingdatasetevents 16-25

Abortingamethod 16-26
UsingOnCalcFields 16-26
Chapter 17
Working with field components 17-1
Dynamicfieldcomponents 17-2
Persistentfieldcomponents 17-3
Creatingpersistentfields 17-4
Arrangingpersistentfields 17-5
Definingnewpersistentfields 17-5
Definingadatafield 17-6
Definingacalculatedfield 17-7
Definingalookupfield 17-8
Defininganaggregatefield 17-10
Deleting persistent field
components 17-10
Setting persistent field properties
andevents 17-10
Setting display and edit properties
atdesigntime 17-11
Setting field component properties
atruntime 17-12
Controlling and masking user
input 17-12
Using default formatting for numeric,
date,andtimefields 17-13
Handlingevents 17-13
Working with field component methods
atruntime 17-14
Displaying, converting, and accessing
fieldvalues 17-15

Displaying field component values in
standardcontrols 17-15
Convertingfieldvalues 17-16
Accessing field values with the default
datasetproperty 17-17
Accessing field values with a dataset’s
Fieldsproperty 17-18
Accessing field values with a dataset’s
FieldByNamemethod 17-18
Checkingafield’scurrentvalue 17-19
Settingadefaultvalueforafield 17-19
Specifyingconstraints 17-19
Usingobjectfields 17-20
DisplayingADTandarrayfields 17-21
WorkingwithADTfields 17-21
Using persistent field components. . . 17-22
Using the dataset’s FieldByName
method 17-22
Using the dateset’s FieldValues
property 17-22
Using the ADT field’s FieldValues
property 17-22
Using the ADT field’s Fields
property 17-23
Workingwitharrayfields 17-23
Usingpersistentfields 17-23
Using the array field’s FieldValues
property 17-23
Using the array field’s Fields
property 17-24

Workingwithdatasetfields 17-24
Displayingdatasetfields 17-24
Accessing data in a nested
dataset 17-24
Workingwithreferencefields 17-25
Displayingreferencefields 17-25
Accessing data in a reference field . . . 17-25
xi
Chapter 18
Using unidirectional datasets 18-1
Types of unidirectional datasets 18-2
ConnectingtotheServer 18-2
Specifyingwhatdatatodisplay 18-3
Representingtheresultsofaquery 18-3
Specifying a query using
TSQLDataSet 18-4
Specifying a query using
TSQLQuery 18-4
Usingparametersinqueries 18-4
Representingtherecordsinatable 18-6
Representing a table using
TSQLDataSet 18-6
Representing a table using
TSQLTable 18-6
Representing the results of a stored
procedure 18-7
Specifying a stored procedure using
TSQLDataSet 18-7
Specifying a stored procedure using
TSQLStoredProc 18-7

Working with stored procedure
parameters 18-7
Fetchingthedata 18-9
Preparingthedataset 18-10
Fetchingmultipledatasets 18-10
Executing commands that do not return
records 18-11
Specifyingthecommandtoexecute 18-11
Executingthecommand 18-12
Creating and modifying server
metadata 18-12
Settingupmaster/detailrelationships 18-13
Setting up master/detail relationships with
TSQLDataSetorTSQLQuery 18-13
Setting up master/detail relationships
withTSQLTable 18-14
Accessingschemainformation 18-15
Fetching data after using the dataset
formetadata 18-16
Thestructureofmetadatadatasets 18-16
Informationabouttables 18-17
Information about stored
procedures 18-17
Informationaboutfields 18-18
Informationaboutindexes 18-19
Information about stored procedure
parameters 18-19
Chapter 19
Connecting to databases 19-1
Controlling connections 19-2

Describingtheserverconnection 19-2
Identifyingthedriver 19-2
Specifying connection parameters . . . . 19-2
Naming a connection description . . . . 19-3
Using the Connection Editor 19-3
Opening and closing server
connections 19-4
Openingaconnection 19-4
Disconnecting from a database
server 19-5
Controlling server login 19-5
Managingtransactions 19-7
Startingatransaction 19-7
Endingatransaction 19-8
Endingasuccessfultransaction 19-8
Ending an unsuccessful transaction . . . 19-9
Specifying the transaction isolation
level 19-9
Accessingservermetadata 19-10
Workingwithassociateddatasets 19-11
Closing datasets without disconnecting
fromtheserver 19-11
Iterating through the associated
datasets 19-11
Sendingcommandstotheserver 19-12
Debuggingdatabaseapplications 19-13
Using TSQLMonitor to monitor SQL
commands 19-13
Using a callback to monitor SQL
commands 19-14

Chapter 20
Using client datasets 20-1
Working with data using a client dataset. . . . 20-2
Navigatingdatainclientdatasets 20-2
Specifying the index to use for
searching 20-3
Executing a search with Goto
methods 20-4
Executing a search with Find
methods 20-4
Specifying the current record after a
successfulsearch 20-5
Searchingonpartialkeys 20-5
Repeating or extending a search . . . . . 20-5
xii
Limitingwhatrecordsappear 20-5
Understanding the differences between
rangesandfilters 20-6
Specifyingranges 20-6
Modifyingarange 20-9
Applyingorcancelingarange 20-9
Representing master/detail
relationships 20-10
Making the client dataset a detail
ofanotherdataset 20-10
Usingnesteddetailtables 20-12
Constrainingdatavalues 20-13
Makingdataread-only 20-14
Editing data . . . 20-14
Undoingchanges 20-15

Savingchanges 20-15
Sortingandindexing 20-16
Addinganewindex 20-16
Deletingandswitchingindexes 20-17
Obtaining information about
indexes 20-17
Usingindexestogroupdata 20-18
Representingcalculatedvalues 20-19
Using internally calculated fields in
clientdatasets 20-19
Usingmaintainedaggregates 20-20
Specifyingaggregates 20-20
Aggregating over groups of
records 20-21
Obtainingaggregatevalues 20-22
Adding application-specific information
tothedata 20-22
Copyingdatafromanotherdataset 20-23
Assigningdatadirectly 20-23
Cloningaclientdatasetcursor 20-24
Usingaclientdatasetwithaprovider 20-24
Specifyingadataprovider 20-25
Getting parameters from the source
dataset 20-26
Passing parameters to the source
dataset 20-26
Sending query or stored procedure
parameters 20-27
Limiting records with parameters . . . 20-27
Specifying the command to execute on

theserver 20-28
Requesting data from the source
dataset 20-29
Incrementalfetching 20-29
Fetch-on-demand 20-30
Updatingrecords 20-30
Applyingupdates 20-31
Reconciling update errors. 20-31
Refreshingrecords 20-33
Communicating with providers using
customevents 20-33
UsinganSQLclientdataset 20-34
WhentouseTSQLClientDataSet 20-34
SettingupanSQLclientdataset 20-35
Configuringtheinternalprovider 20-36
Using a client dataset with file-based
data 20-37
Creatinganewdataset 20-37
Creating a new dataset using
persistentfields 20-38
Creating a dataset using field and
indexdefinitions 20-38
Creating a dataset based on an
existingtable 20-39
Loading data from a file or stream . . . . 20-40
Mergingchangesintodata 20-40
Savingdatatoafileorstream 20-41
Chapter 21
Using provider components 21-1
Determiningthesourceofdata 21-2

Communicating with the client dataset . . . . 21-2
Choosinghowtoapplyupdates 21-3
Controlling what information is included
indatapackets 21-4
Specifying what fields appear in
datapackets 21-4
Setting options that influence the
datapackets 21-4
Adding custom information to
datapackets 21-6
Respondingtoclientdatarequests 21-6
Respondingtoclientupdaterequests 21-7
Editing delta packets before updating
thedatabase 21-8
Influencing how updates are applied . . . . 21-8
Screeningindividualupdates 21-10
Resolving update errors on the
provider 21-10
Applying updates to datasets that do
notrepresentasingletable 21-10
Responding to client-generated events . . . . .21-11
xiii
Part III
Writing distributed applications
Chapter 22
Creating Internet server
applications 22-1
Terminologyandstandards 22-1
PartsofaUniformResourceLocator 22-2
URIvs.URL 22-2

HTTPrequestheaderinformation 22-2
HTTPserveractivity 22-3
Composingclientrequests 22-3
ServingCGIrequests 22-4
Serving dynamic shared object
requests 22-4
Webserverapplications 22-4
TypesofWebserverapplications 22-4
CGIstand-alone 22-5
ApacheDSOmodule 22-5
CreatingWebserverapplications 22-5
TheWebmodule 22-5
TheWebApplicationobject 22-6
ThestructureofaWebserverapplication 22-6
TheWebdispatcher 22-7
Addingactionstothedispatcher 22-7
Dispatchingrequestmessages 22-8
Actionitems 22-8
Determiningwhenactionitemsfire 22-9
ThetargetURL 22-9
Therequestmethodtype 22-9
Enabling and disabling action
items 22-9
Choosingadefaultactionitem 22-10
Responding to request messages with
actionitems 22-10
Sendingtheresponse 22-11
Usingmultipleactionitems 22-11
Accessingclientrequestinformation 22-11
Properties that contain request header

information 22-11
Propertiesthatidentifythetarget 22-12
Properties that describe the Web
client 22-12
Properties that identify the purpose
oftherequest 22-12
Properties that describe the expected
response 22-13
Properties that describe the
content 22-13
The content of HTTP request
messages 22-13
CreatingHTTPresponsemessages 22-13
Fillingintheresponseheader 22-14
Indicatingtheresponsestatus 22-14
Indicating the need for client
action 22-14
Describing the server application . . . 22-14
Describingthecontent 22-15
Settingtheresponsecontent 22-15
Sendingtheresponse 22-15
Generating the content of response
messages 22-16
Usingpageproducercomponents 22-16
HTMLtemplates 22-16
SpecifyingtheHTMLtemplate 22-17
Converting HTML-transparent
tags 22-17
Using page producers from an
actionitem 22-18

Chaining page producers
together 22-18
Using database information in
responses 22-20
Adding a session to the Web module . . . 22-20
Representing database information
inHTML 22-20
Usingdatasetpageproducers 22-20
Usingtableproducers 22-21
Specifyingthetableattributes 22-21
Specifyingtherowattributes 22-21
Specifyingthecolumns 22-21
Embedding tables in HTML
documents 22-22
Setting up a dataset table
producer 22-22
Setting up a query table
producer 22-22
Debuggingserverapplications 22-23
DebuggingCGIapplications 22-23
Debuggingasasharedobject 22-23
Debugging Apache DSO
applications 22-23
Compiling an Apache application
forDSOsupport 22-23
Debugging Apache DSO
applications 22-24
xiv
Chapter 23
Working with sockets 23-1

Implementingservices 23-1
Understandingserviceprotocols 23-2
Communicatingwithapplications 23-2
Servicesandports 23-2
Typesofsocketconnections 23-2
Clientconnections 23-3
Listeningconnections 23-3
Serverconnections 23-3
Describingsockets 23-3
Describingthehost 23-4
Choosing between a host name and
anIPaddress 23-4
Usingports 23-5
Usingsocketcomponents 23-5
Usingclientsockets 23-5
Specifyingthetargetserver 23-6
Formingtheconnection 23-6
Getting information about the
connection 23-6
Closingtheconnection 23-6
Usingserversockets 23-6
Specifyingtheport 23-6
Listeningforclientrequests 23-7
Connectingtoclients 23-7
Closingserverconnections 23-7
Respondingtosocketevents 23-7
Errorevents 23-7
Clientevents 23-8
Serverevents 23-8
Eventswhenlistening 23-8

Eventswithclientconnections 23-8
Reading and writing over socket
connections 23-9
Non-blockingconnections 23-9
Readingandwritingevents 23-9
Blockingconnections 23-10
Part IV
Creating custom components
Chapter 24
Overview of component creation 24-1
Component Library for Cross Platform
(CLX) 24-1
Componentsandclasses 24-2
Howtocreatecomponents? 24-2
Modifyingexistingcontrols 24-3
Creatingcontrols 24-4
Creatinggraphiccontrols 24-4
Subclassingcontrols 24-4
Creatingnonvisualcomponents 24-5
Whatgoesintoacomponent? 24-5
Removingdependencies 24-5
Properties,methods,andevents 24-6
Properties 24-6
Events 24-6
Methods 24-6
Graphicsencapsulation 24-7
Registration 24-7
Creatinganewcomponent 24-8
UsingtheComponentwizard 24-8
Creatingacomponentmanually 24-10

Creatingaunitfile 24-10
Derivingthecomponent 24-10
Registeringthecomponent 24-11
Testinguninstalledcomponents 24-12
Testinginstalledcomponents 24-13
Chapter 25
Object-oriented programming for
component writers 25-1
Definingnewclasses 25-1
Derivingnewclasses 25-2
To change class defaults to avoid
repetition 25-2
To add new capabilities to a class . . . . 25-2
Declaringanewcomponentclass 25-3
Ancestors, descendants, and class
hierarchies 25-3
Controlling access. . . 25-4
Hidingimplementationdetails 25-4
Defining the component writer’s
interface 25-5
Definingtheruntimeinterface 25-6
Definingthedesign-timeinterface 25-6
Dispatchingmethods 25-7
Staticmethods 25-7
Virtualmethods 25-8
Overridingmethods 25-8
Abstractclassmembers 25-9
Classesandpointers 25-9
Chapter 26
Creating properties 26-1

Whycreateproperties? 26-1
Typesofproperties 26-2
xv
Publishinginheritedproperties 26-3
Definingproperties 26-3
Thepropertydeclaration 26-3
Internaldatastorage 26-4
Directaccess 26-4
Accessmethods 26-5
Thereadmethod 26-6
Thewritemethod 26-6
Defaultpropertyvalues 26-7
Specifyingnodefaultvalue 26-7
Creatingarrayproperties 26-8
Creatingpropertiesforsubcomponents 26-9
Creatingpropertiesforinterfaces 26-10
Storingandloadingproperties 26-11
Using the store-and-load mechanism . . . 26-11
Specifyingdefaultvalues 26-11
Determiningwhattostore 26-12
Initializingafterloading 26-13
Storing and loading unpublished
properties 26-13
Creating methods to store and load
propertyvalues 26-13
Overriding the DefineProperties
method 26-14
Chapter 27
Creating events 27-1
Whatareevents? 27-1

Eventsaremethodpointers 27-2
Eventsareproperties 27-2
Eventtypesaremethod-pointertypes 27-3
Event-handler types are procedures . . .27-3
Eventhandlersareoptional 27-4
Implementingthestandardevents 27-4
Identifyingstandardevents 27-4
Standardeventsforallcontrols 27-4
Standard events for widget-based
controls 27-5
Makingeventsvisible 27-5
Changing the standard event
handling 27-5
Definingyourownevents 27-6
Triggeringtheevent 27-6
Twokindsofevents 27-7
Definingthehandlertype 27-7
Simplenotifications 27-7
Event-specifichandlers 27-7
Returning information from the
handler 27-8
Declaringtheevent 27-8
Eventnamesstartwith“On” 27-8
Callingtheevent 27-8
Chapter 28
Creating methods 28-1
Avoidingdependencies 28-1
Namingmethods 28-2
Protectingmethods 28-2
Methodsthatshouldbepublic 28-3

Methodsthatshouldbeprotected 28-3
Abstractmethods 28-3
Makingmethodsvirtual 28-4
Declaringmethods 28-4
Chapter 29
Using graphics in components 29-1
Usingthecanvas 29-1
Workingwithpictures 29-2
Usingapicture,graphic,orcanvas 29-2
Loadingandstoringgraphics 29-3
Off-screenbitmaps 29-3
Creating and managing off-screen
bitmaps 29-4
Copyingbitmappedimages 29-4
Respondingtochanges 29-5
Chapter 30
Making components available
at design time 30-1
Registeringcomponents 30-1
DeclaringtheRegisterprocedure 30-2
WritingtheRegisterprocedure 30-2
Specifyingthecomponents 30-2
Specifyingthepalettepage 30-3
Using the RegisterComponents
function 30-3
Addingpalettebitmaps 30-3
Addingpropertyeditors 30-4
Derivingaproperty-editorclass 30-4
Editing the property as text . 30-5
Displayingthepropertyvalue 30-6

Settingthepropertyvalue 30-6
Editing the property as a whole 30-7
Specifyingeditorattributes 30-8
Registeringthepropertyeditor 30-9
Propertycategories 30-10
Registering one property at a time . . . . 30-10
xvi
Registering multiple properties
atonce 30-11
Specifyingpropertycategories 30-12
Using the IsPropertyInCategory
function 30-12
Addingcomponenteditors 30-13
Addingitemstothecontextmenu 30-13
Specifyingmenuitems 30-14
Implementingcommands 30-14
Changingthedouble-clickbehavior 30-15
Addingclipboardformats 30-15
Registeringthecomponenteditor 30-16
Compiling components into packages. 30-16
Chapter 31
Modifyinganexisting
component 31-1
Creatingandregisteringthecomponent 31-1
Modifyingthecomponentclass 31-2
Overridingtheconstructor 31-2
Specifying the new default property
value 31-3
Chapter 32
Creating a graphic component 32-1

Creatingandregisteringthecomponent 32-1
Publishinginheritedproperties 32-2
Adding graphic capabilities . 32-3
Determiningwhattodraw 32-3
Declaringthepropertytype 32-3
Declaringtheproperty 32-4
Writing the implementation
method 32-4
Overriding the constructor and
destructor 32-4
Changingdefaultpropertyvalues 32-4
Publishingthepenandbrush 32-5
Declaringtheclassfields 32-5
Declaringtheaccessproperties 32-6
Initializingownedclasses 32-6
Settingownedclasses’properties 32-7
Drawingthecomponentimage 32-8
Refiningtheshapedrawing 32-9
Chapter 33
Customizing a grid 33-1
Creating and registering the component . . . . 33-1
Publishinginheritedproperties 33-2
Changinginitialvalues 33-3
Resizingthecells 33-4
Fillinginthecells 33-4
Trackingthedate 33-5
Storingtheinternaldate 33-5
Accessingtheday,month,andyear. . . 33-6
Generatingthedaynumbers 33-7
Selectingthecurrentday 33-9

Navigatingmonthsandyears 33-9
Navigatingdays 33-10
Movingtheselection 33-10
ProvidinganOnChangeevent 33-11
Excludingblankcells 33-12
Chapter 34
Making a control data aware 34-1
Creatingadata-browsingcontrol 34-1
Creating and registering the
component 34-2
Makingthecontrolread-only 34-2
Adding the ReadOnly property . . . . . 34-2
Allowingneededupdates 34-3
Addingthedatalink 34-4
Declaringtheclassfield 34-4
Declaringtheaccessproperties 34-5
An example of declaring access
properties 34-5
Initializingthedatalink 34-6
Respondingtodatachanges 34-6
Creatingadata-editingcontrol 34-7
Changing the default value of
FReadOnly 34-8
Handling mouse-down and key-down
events 34-8
Responding to mouse-down events . . . 34-8
Respondingtokey-downevents 34-9
Updatingthefielddatalinkclass 34-10
ModifyingtheChangemethod 34-10
Updatingthedataset 34-11

Index I-1
xvii
1.1 Typefacesandsymbols 1-2
3.1 Importantbaseclasses 3-12
3.2 Graphiccontrols 3-16
3.3 Componentpalettepages 3-18
3.4 Textcontrolproperties 3-19
3.5 Components for creating and
managinglists 3-32
4.1 RTLexceptions 4-9
4.2 ObjectPascalcharactertypes 4-25
4.3 Stringcomparisonroutines 4-29
4.4 Caseconversionroutines 4-29
4.5 Stringmodificationroutines 4-29
4.6 Substringroutines 4-30
4.7 Stringhandlingroutines 4-30
4.8 Compilerdirectivesforstrings 4-34
4.9 Attributeconstantsandvalues 4-36
4.10FiletypesforfileI/O 4-38
4.11 Openmodes 4-39
4.12Sharemodes 4-39
4.13 Shared modes available for each
openmode 4-40
5.1 Compilerdirectivesforlibraries 5-4
6.1 Actioncategories 6-18
6.2 Sample captions and their derived
names 6-22
6.3 Menu Designer context menu
commands 6-27
6.4 Settingspeedbuttons’appearance 6-33

6.5 Settingtoolbuttons’appearance 6-35
7.1 Propertiesofselectedtext 7-3
7.2 Fixed vs. variable owner-draw
styles 7-7
8.1 Graphicobjecttypes 8-3
8.2 Common properties of the Canvas
object 8-3
8.3 Common methods of the Canvas
object 8-4
8.4 Mouseevents 8-23
8.5 Mouse-eventparameters 8-23
9.1 WaitForreturnvalues 9-9
10.1Portingtechniques 10-2
10.2CLXparts 10-4
10.3Changedordifferentfeatures 10-7
10.4UnitsinKylixandDelphi 10-8
10.5UnitsinKylix,notinDelphi 10-10
10.6UnitsinDelphi,notinKylix 10-10
10.7 Differences in the Linux operating
environment 10-12
10.8CommonLinuxdirectories 10-14
10.9 TWidgetControl protected methods
for responding to system events . . . . 10-19
10.10 Comparable data-access
components 10-22
10.11 Properties, methods, and events
forcachedupdates 10-26
11.1 Compiledpackagefiles 11-2
11.2 Design-timepackages 11-5
11.3 Package-specific compiler

directives 11-10
11.4 Package-specific command-line
compilerswitches 11-11
11.5 Compiledpackagefiles 11-12
12.1Estimatingstringlengths 12-4
12.2Resbindoptions 12-7
15.1Datacontrols 15-2
15.2Columnproperties 15-19
15.3 Expanded TColumn Title
properties 15-19
15.4 Properties that affect the way
compositefieldsappear 15-21
15.5 Expanded TDBGrid Options
properties 15-22
15.6Gridcontrolevents 15-24
15.7TDBNavigatorbuttons 15-25
16.1 Values for the dataset State
property 16-3
16.2 Navigational methods of datasets . . . . 16-9
16.3 Navigational properties of datasets. . . . 16-9
16.4 Operators that can appear in
afilter 16-17
16.5FilterOptionsvalues 16-19
16.6 Filtered dataset navigational
methods 16-20
16.7 Dataset methods for inserting,
updating,anddeletingdata 16-21
16.8 Methods that work with entire
records 16-24
16.9Datasetevents 16-25

17.1 TFloatField properties that affect
datadisplay 17-1
17.2Specialpersistentfieldkinds 17-6
17.3Fieldcomponentproperties 17-11
Tables
xviii
17.4 Field component formatting
routines 17-13
17.5Fieldcomponentevents 17-14
17.6 Selected field component methods . . . 17-15
17.7Specialconversionresults 17-17
17.8Typesofobjectfieldcomponents 17-20
17.9 Common object field descendant
properties 17-21
18.1 Columnsintablesofmetadata
listingtables 18-17
18.2 Columnsintablesofmetadata
listingstoredprocedures 18-17
18.3 Columnsintablesofmetadata
listingfields 18-18
18.4 Columnsintablesofmetadata
listingindexes 18-19
18.5 Columns in tables of metadata listing
parameters 18-19
20.1Index-basedsearchmethods 20-3
20.2 Summary operators for maintained
aggregates 20-21
20.3 Client datasets properties and method
forhandlingdatarequests 20-29
21.1AppServerinterfacemembers 21-3

21.2Provideroptions 21-4
21.3UpdateStatusvalues 21-8
21.4UpdateModevalues 21-9
21.5ProviderFlagsvalues 21-9
22.1 Web server application
components 22-4
22.2MethodTypevalues 22-9
24.1 Component creation starting points . . . 24-3
25.1 Levels of visibility within an object. . . . 25-4
26.1 How properties appear in the
ObjectInspector 26-2
29.1 Canvas capability summary 29-2
29.2Image-copyingmethods 29-4
30.1 Predefined property-editor types . . . . . 30-5
30.2 Methods for reading and writing
propertyvalues 30-6
30.3Property-editorattributeflags 30-8
30.4Propertycategories 30-12
Figures
3.1 CLXorganization 3-2
3.2 Asimpleform 3-6
3.3 Asimplifiedhierarchydiagram 3-12
3.4 Three views of the track bar
component 3-21
3.5 Aprogressbar 3-29
6.1 A frame with data-aware controls and
adatasourcecomponent 6-13
6.2 Menuterminology 6-20
6.3 MainMenu and PopupMenu
components 6-20

6.4 MenuDesignerforapop-upmenu 6-21
6.5 MenuDesignerforamainmenu 6-21
6.6 Nestedmenustructures 6-25
6.7 SelectMenudialogbox 6-28
6.8 Sample Insert Template dialog box
formenus 6-29
6.9 Save Template dialog box for
menus 6-30
14.1GenericDatabaseArchitecture 14-5
14.2 Architecture of a file-based
databaseapplication 14-7
14.3 Architecture of a unidirectional
databaseapplication 14-8
14.4 Architecture combining a client dataset
andaunidirectionaldataset 14-9
14.5 Architecture using a client dataset with
an internal unidirectional dataset . . . . 14-10
14.6 Multi-tiered database architecture . . . .14-11
15.1TDBGridcontrol 15-14
15.2 Buttons on the TDBNavigator
control 15-25
16.1 Relationship of Inactive and
Browsestates 16-5
16.2 Relationship of Browse to other
datasetstates 16-6
22.1 Parts of a Uniform Resource
Locator 22-2
22.2StructureofaServerApplication 22-7
24.1CLXclasshierarchy 24-2
Introduction

1-1
Chapter
1
Chapter1Introduction
The Developer’s Guide describes intermediate and advanced development topics, such
as building database applications, writing custom components, and creating Internet
Web server applications using Kylix, Delphi for the Linux operating system. The
Developer’s Guide assumes you are familiar with using Linux and understand
fundamental programming techniques. For an introduction to Kylix programming
and the integrated development environment (IDE), see the online Help and the
Quick Start manual.
What’s in this manual?
This manual contains the following parts:

Part I, “Programming with Kylix,”
describes how to build general-purpose Kylix
applications. This part provides details on programming techniques you can use
in any Kylix application. For example, it describes how to use common Borland
Component Library for Cross Platform (CLX) objects that simplify user interface
development such as handling strings and manipulating text. It also includes
chapters on working with graphics, controls, error and exception handling, and
writing international applications. The chapter on deployment describes the tasks
involved in deploying your application to your application users.

Part II, “Developing database applications,”
describes how to build database
applications using database tools and components. Kylix lets you access SQL
server databases using DBExpress. Your version of Kylix comes with a set of
DBExpress drivers for connecting to specific databases. Additional DBExpress
drivers for connecting to other databases are available for purchase separately.


Part III, “Writing distributed applications,”
describes how to create applications
that are distributed over a local area network. These include Web server
applications, such as Apache and CGI applications. For lower-level support of
distributed applications, this section also describes how to work with socket
components, that handle the details of communication using TCP/IP and related
1-2
Developer’s Guide
Manual conventions
protocols. The components that support sockets and Web server applications are
not available in the standard edition of Kylix.

Part IV, “Creating custom components,”
describes how to design and implement
your own components, and how to make them available on the Component
palette in Kylix’s development environment. A component can represent almost
any program element that you want to manipulate at design time. Implementing
custom components involves deriving a new class from an existing class type in
the CLX class library.
Manual conventions
This manual uses the typefaces and symbols described in Table 1.1 to indicate special
text.
Developer support services
Borland also offers a variety of support options to meet the needs of its diverse
developer community. To find out about support offerings for Kylix, refer to
Additional Kylix Technical Information
documents and answers to Frequently Asked Questions (FAQs) are also available at
this Web site.
From the Web site, you can access many newsgroups where Kylix developers

exchange information, tips, and techniques.
Refer also to the Borland Community site at . It
provides access to lots of information, articles, code examples, and upcoming news
about Kylix.
Ordering printed documentation
For information about ordering additional documentation, refer to the Web site at
shop.borland.com.
Table 1.1
Typefaces and symbols
Typeface or symbol Meaning
Monospace type Monospaced text represents text as it appears on screen or in Object Pascal
code. It also represents anything you must type.
[ ] Square brackets in text or syntax listings enclose optional items. Text of this
sort should not be typed verbatim.
Boldface Boldfaced words in text or code listings represent Object Pascal keywords
or compiler options.
Italics Italicized words in text represent Object Pascal identifiers, such as variable
or type names. Italics are also used to emphasize certain words, such as
new terms.
Keycaps This typeface indicates a key on your keyboard. For example, “Press Esc to
exit a menu.”
Programming with Kylix
Part
I
Part IProgramming with Kylix
The chapters in “Programming with Kylix” introduce concepts and skills necessary
for creating Kylix applications. They also introduce the concepts discussed in later
sections of the Developer’s Guide.

Developing applications with Kylix

2-1
Chapter
2
Chapter 2Developing applications with Kylix
Borland Kylix is an object-oriented, visual programming environment for rapid
development of 32-bit applications. Using Kylix, you can create highly efficient cross-
platform applications with a minimum of manual coding.
Kylix provides a comprehensive class library called the Borland Component Library
for Cross Platform (CLX) and a suite of Rapid Application Development (RAD)
design tools, including application and form templates, and programming wizards.
Kylix supports truly object-oriented programming: the class library includes many
useful objects that you can use while developing applications.
This chapter briefly describes the Kylix development environment. The rest of this
manual provides technical details on developing general-purpose, database, Internet
and Intranet applications, and includes information on writing your own
components.
Integrated development environment
When you start Kylix, you are immediately placed within the integrated
development environment, also called the IDE. This environment provides all the
tools you need to design, develop, test, debug, and deploy applications.
Kylix’s development environment includes a visual form designer, Object Inspector,
Component palette, Project Manager, source code editor, and debugger. You can
move freely from the visual representation of an object (in the form designer), to the
Object Inspector to edit the initial runtime state of the object, to the source code editor
to edit the execution logic of the object. Changing code-related properties, such as the
name of an event handler, in the Object Inspector automatically changes the
corresponding source code. In addition, changes to the source code, such as
renaming an event handler method in a form class declaration, is immediately
reflected in the Object Inspector.
2-2

Developer’s Guide
Designing applications
The IDE supports application development throughout the stages of the product life
cycle—from design to deployment. Using the tools in the IDE allows for rapid
prototyping and shortens development time.
A more complete overview of the development environment is presented in the
Quick Start manual included with the product. In addition, the online Help system
provides help on all menus, dialogs, and windows.
Designing applications
Kylix includes all the tools necessary for you to start designing applications:
• A blank window, known as a form, on which to design the UI for your application.
• An extensive class library (CLX) that contains many reusable objects.
• An Object Inspector for examining and changing object traits.
• A Code editor that provides direct access to the underlying program logic.
• A Project Manager for managing the files that make up one or more projects.
• Many other tools such as an integrated debugger to support application
development in the IDE.
• Command-line tools including compilers, linkers, and other utilities.
You can use Kylix to design any kind of 32-bit application—from general-purpose
utilities to sophisticated data access programs or distributed applications. Kylix’s
database tools and data-aware components let you quickly develop powerful
desktop database and client/server applications. Using Kylix’s data-aware controls,
you can view live data while you design your application and immediately see the
results of database queries and changes to the application interface.
Many of the objects provided in the class library are accessible in the IDE from the
component palette. The component palette shows all of the controls, both visual and
nonvisual, that you can place on a form. Each tab contains components grouped by
functionality. By convention, the names of objects in the class library begin with a T,
such as TStatusBar.
One of the revolutionary things about Kylix is that you can create your own

components using Object Pascal. Most of the components provided are written in
Object Pascal. You can add components that you write to the component palette and
customize the palette for your use by including new tabs if needed.
Chapter 5, “Building applications and shared objects” introduces Kylix’s support for
different types of applications.
Developing applications
As you visually design the user interface for your application, Kylix generates the
underlying Object Pascal code to support the application. As you select and modify
the properties of components and forms, the results of those changes appear
automatically in the source code, and vice versa. You can modify the source files
directly with any text editor, including the built-in Code editor. The changes you
Developing applications with Kylix
2-3
Developing applications
make are immediately reflected in the visual environment as well. This feature is
called “two-way tools.”
Creating projects
All of Kylix’s application development revolves around projects. When you create an
application in Kylix you are creating a project. A project is a collection of files that
make up an application. Some of these files are created at design time. Others are
generated automatically when you compile the project source code.
You can view the contents of a project in a project management tool called the Project
Manager. The Project Manager lists, in a hierarchical view, the unit names, the forms
contained in the unit (if there is one), and shows the paths to the files in the project.
Although you can edit many of these files directly, it is often easier and more reliable
to use the visual tools in Kylix.
At the top of the project hierarchy, is a group file. You can combine multiple projects
into a project group. This allows you to open more than one project at a time in the
Project Manager. Project groups let you organize and work on related projects, such
as applications that function together or parts of a multi-tiered application. If you are

only working on one project, you do not need a project group file to create an
application.
Project files, which describe individual projects, files, and associated options, have a
.dpr extension. Project files contain directions for building an application or shared
object. When you add and remove files using the Project Manager, the project file is
updated. You specify project options using a Project Options dialog which has tabs
for various aspects of your project such as forms, application, compiler. These project
options are stored in the project file with the project.
Units and forms are the basic building blocks of a Kylix application. A project can
share any existing form and unit file including those that reside outside the project
directory tree. This includes custom procedures and functions that have been written
as standalone routines.
If you add a shared file to a project, realize that the file is not copied into the current
project directory; it remains in its current location. Adding the shared file to the
current project registers the file name and path in the
uses
clause of the project file.
Kylix automatically handles this as you add units to a project.
When you compile a project, it does not matter where the files that make up the
project reside. The compiler treats shared files the same as those created by the
project itself.
Editing code
The Kylix Code editor is a full-featured ASCII editor. If using the visual
programming environment, a form is automatically displayed as part of a new
project. You can start designing your application interface by placing objects on the
form and modifying how they work in the Object Inspector. But other programming
tasks, such as writing event handlers for objects, must be done by typing the code.

×