ebook img

Essential Delphi 3 fast : Includes ActiveX Development PDF

197 Pages·1998·11.1 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Essential Delphi 3 fast : Includes ActiveX Development

Essential Series Springer London Berlin Heidelberg New York Barcelona Budapest Hong Kong Milan Paris Santa Clara Singapore Tokyo Also in this series: John Cowell Essential Visual Basic 4.0 Fast 3-540-19998-5 John Cowell Essential Delphi 2.0 Fast 3-540-76026-1 John Cowell Essential Java Fast 3-540-76052-0 John Cowell Essential Visual Basic 5.0 Fast 3-540-76148-9 Duncan Reed and Peter Thomas Essential HTML Fast 3-540-76199-3 John Cowell Essential Delphi 3 fast Includes ActiveX Development With 179 figures , Springer Author and Series Editor John Cowell, BSc (Hons), MPhil, PhD Department of Computer and Information Sciences De Montfort University, Kents Hill Campus, Hammerwood Gate, Kents Hill, Milton Keynes, MK7 6HP, UK ISBN-13: 978-3-540-76150-1 e-ISBN-13: 978-1-4471-1518-2 001: 10.1007/978-1-4471-1518-2 British Library Cataloguing in Publication Data Cowell, John, 1957- Essential Delphi 3.0 fast : includes ActiveX control development I.Delphi (Computer program language) 1.Title II.Delphi 3.0 fast 005.2'62 Library of Congress Cataloging-in-Publication Data Cowell, John, 1957- Essential Delphi 3.0 fast : jincludes ActiveX control development 1 John Cowell. p. cm. -- (Essential series) Incl udes index. ISBN-13: 978-3-540-76150-1 1. Computer software--Development. 2. Delphi (Computer file) 1. Title. II. Series: Essential series (springer-Verlag) QA76.76.D47C68 1997 97-40559 005.26'8--dc21 CIP Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers, or in the case of repro graphic reproduction in accordance with the terms oflicences issued by the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be sent to the publishers. © Springer-Verlag London Limited 1998 Softcover reprint of the hardcover 1s t edition 1998 Microsoft, MS, Visual Basic, Windows and Windows 95 are trademarks of Microsoft Corporation Ltd. Delphi is a trademark of Borland Ltd. The use of registered names, trademarks etc. in this publication does not imply, even in the absence of a specific statement, tlIat such names are exempt from the relevant laws and regulations and therefore free for general use. The publisher makes no representation, express or implied, with regard to the accuracy of the information contained in this book and cannot accept any legal responsibility or liability for any errors or omissions that may be made. Typesetting: Camera ready by author 34/3830-543210 Printed on acid-free paper Contents 1 WHY USE DELPHI 3? .................................................................................. 1 Introduction .............................................................................................. 1 What this book covers .............................................................................. 2 Getting started .......................................................................................... 2 What computer you need to run Delphi 3 ................................................. 3 What's new in Delphi 3 ............................................................................. 3 Converting from Delphi 2 to Delphi 3 ...................................................... 4 Conventions .............................................................................................. 4 2 THE DELPHI ENVIRONMENT ..................................................................... 5 Introduction .............................................................................................. 5 Running Delphi ........................................................................................ 5 The Delphi Environment .......................................................................... 7 The design form ........................................................................................ 8 The Component Palette ............................................................................ 9 The Object Inspector .............................................................................. 10 The unit window ..................................................................................... 11 The menu ................................................................................................ 11 The SpeedBar ......................................................................................... 12 Finding windows .................................................................................... 12 3 THE STANDARD COMPONENT PALETTE .............................................. 13 Introduction ............................................................................................ 13 Event Driven Software ........................................................................... 13 Changing component properties ............................................................. 14 The Label component ............................................................................. 16 The Edit component ............................................................................... 16 The Memo component ............................................................................ 17 The Button component ........................................................................... 18 The CheckBox component ..................................................................... 19 The RadioButton component .................................................................. 20 The ListBox component ......................................................................... 20 The ComboBox component. ................................................................... 21 The ScrollBar component ....................................................................... 22 The GroupBox and RadioGroup components ........................................ 23 The Panel component ............................................................................. 23 MainMenu and PopupMenu ................................................................... 24 Using the components ............................................................................ 24 vi Contents 4 USING THE STANDARD COMPONENTS ................................................ 25 Introduction .................................................................................... ". ...... 25 The Changeling application ................................................................... 25 Creating the user interface ...................................................................... 26 Adding the Memo and Panel components .............................................. 27 Adding the ListBox and ComboBox components .................................. 27 Adding the RadioButtons ....................................................................... 27 Completing the user interface ................................................................ 28 Changing the text colour ........................................................................ 29 Changing the background colour ........................................................... 31 Changing the text size ............................................................................ 31 Changing the font ................................................................................... 32 Italic ising the text and closing the application ....................................... 33 The completed code ............................................................................... 33 An easier technique ................................................................................ 35 5 THE ADDITIONAL COMPONENT PALETTE ............................................ 37 Introduction ............................................................................................ 37 The BitBtn component ........................................................................... 37 The SpeedButton component ................................................................. 38 The MaskEdit component ...................................................................... 39 The StringGrid component ..................................................................... 41 The DrawGrid component ...................................................................... 42 The Image component ............................................................................ 43 The Shape component ............................................................................ 43 The Bevel component ............................................................................ 44 The ScrollBox component. ..................................................................... 45 The CheckListBox component ............................................................... 46 The Splitter component .......................................................................... 46 The StaticText component ..................................................................... 47 The Chart component ............................................................................. 47 6 DISPLAYING AND READING TEXT ......................................................... 51 Introduction ............................................................................................ 51 The ShowMessage procedure ................................................................. 51 The MessageDlg function ...................................................................... 52 What button was pressed? ...................................................................... 53 Creating input forms .............................................................................. 54 Standard dialog boxes ............................................................................ 55 Displaying dates and times ..................................................................... 57 Displaying numbers ............................................................................... 59 Contents vii 7 USING FORMS .......................................................................................... 61 Introduction ............................................................................................ 61 Creating new forms ................................................................................ 61 Finding forms ......................................................................................... 63 Modal and modeless forms ..................................................................... 63 Displaying forms .................................................................................... 64 Unit files ................................................................................................. 65 The Dialogs page .................................................................................... 68 The OpenDialog component. .................................................................. 68 The SaveDialog component ................................................................... 70 The OpenPictureDialog component ....................................................... 70 The SavePictureDialog component ........................................................ 71 The FontDialog component .................................................................... 71 The ColorDialog component .................................................................. 72 The PrintDialog component ................................................................... 73 The PrinterSetupDialog component ....................................................... 74 The FindDialog component .................................................................... 74 The ReplaceDialog component .............................................................. 75 SDI and MDI forms ................................................................................ 75 Creating parent and child forms ............................................................. 76 Displaying child forms ........................................................................... 76 Closing child forms ................................................................................ 77 Arranging forms ..................................................................................... 78 The Object Repository ............................................................................ 78 8 OBJECT PASCAL ..................................................................................... 80 Introduction ............................................................................................ 80 Standard data types ................................................................................. 80 Declaring variables ................................................................................. 82 Declaring constants ................................................................................ 82 Converting between types ...................................................................... 82 Operators ................................................................................................ 85 Bitwise operators .................................................................................... 86 Controlling program flow ....................................................................... 87 If then else statements ............................................................................. 87 Case statements ....................................................................................... 89 Repeat statements ................................................................................... 90 While statements ..................................................................................... 92 For statements ......................................................................................... 92 Calling procedures and functions ........................................................... 93 Passing by value and address .................................................................. 94 Using functions ....................................................................................... 95 viii Contents 9 CREATING RECORDS, CLASSES AND OBJECTS ................................ 97 Introduction ............................................................................................ 97 Defming data types ................................................................................ 97 Enumerated types ................................................................................... 98 Sub-range types ...................................................................................... 99 Arrays ................................................................................................... 100 Records ................................................................................................. 101 Why bother with object orientation? .................................................... 102 Classes and Objects .............................................................................. 102 Using properties and methods .............................................................. 103 Creating classes .................................................................................... 104 10 CREATING ACTIVE FORMS ................................................................. 107 Introduction .......................................................................................... 107 Writing Web pages ............................................................................... 107 Using Java ............................................................................................ 108 ActiveX components ............................................................................ 109 ActiveX and Java ................................................................................. 109 The Active Form .................................................................................. 109 Starting the application ......................................................................... 110 What the application does .................................................................... 111 Creating the User Interface .................................................................. 111 The Object Pascal code ........................................................................ 112 Web Deployment ................................................................................. 116 The Web page created .......................................................................... 117 Running the application ....................................................................... 118 11 MOUSE AND KEYBOARD EVENTS ..................................................... 120 Introduction .......................................................................................... 120 The mouse events ................................................................................. 120 Tracking mouse movement .................................................................. 121 OnMouseDown and OnMouseUp events ............................................. 122 Dragging and dropping ........................................................................ 122 Dragging to the right position .............................................................. 123 The keyboard events ............................................................................ 125 Using the OnKeyDown event .............................................................. 126 The KeyPreview property .................................................................... 127 12 CREATING AND USING GRAPHICS .................................................... 128 Introduction .......................................................................................... 128 The graphics controls ........................................................................... 128 Creating Images ................................................................................... 129 Contents ix The Tools Palette .................................................................................. 129 Editing images ...................................................................................... 131 Testing bitmaps, icons and cursors ....................................................... 132 Images, cursors and icons ..................................................................... 133 Using Text ............................................................................................ 133 Using Colour ........................................................................................ 134 Adding graphics at run-time ................................................................. 135 The Pen property .................................................................................. 135 Drawing lines ........................................................................................ 136 Drawing shapes .................................................................................... 137 The Brush property ............................................................................... 138 The Style property ................................................................................ 139 The Pixels property ............................................................................... 140 The ColorDialog ................................................................................... 140 Using the clipboard. .............................................................................. 141 13 MENUS ................................................................................................... 142 Introduction .......................................................................................... 142 Main menus and popup menus ............................................................. 142 Adding, inserting and deleting menu items .......................................... 143 Separator bars, accelerator and shortcut keys ....................................... 143 Creating sub-menus .............................................................................. 144 Designing popup menus ....................................................................... 145 Menu events ......................................................................................... 145 Changing the font and colour ............................................................... 148 The Menu Designer speed-menu .......................................................... 149 Menu templates .................................................................................... 150 Creating menu templates ...................................................................... 151 14 USING DATABASES ............................................................................. 152 Introduction .......................................................................................... 152 Relational data ...................................................................................... 152 What databases can Delphi use ............................................................. 153 Creating database applications fast.. ..................................................... 153 The Data Forms Wizard ....................................................................... 154 The Database Desktop .......................................................................... 159 Creating a new table ............................................................................. 159 Desktop tools ........................................................................................ 161 Adding data to a new table ................................................................... 162 Reading the table .................................................................................. 162 Using data controls ............................................................................... 163 The Table component ........................................................................... 163 The DataSource component ................................................................. 164 x Contents Data aware components ....................................................................... 164 15 FIXING BUGS ........................................................................................ 165 Introduction .......................................................................................... 165 Types of errors ..................................................................................... 165 Code Insight......................................................................................... 166 Run-time errors .................................................................................... 168 Logic errors .......................................................................................... 169 Stopping the application ....................................................................... 170 Using breakpoints ................................................................................. 171 Restarting after breakpoints ................................................................. 171 Viewing breakpoints ............................................................................ 171 Stepping ............................................................................................... 172 The Debug toolbar. ............................................................................... 172 Viewing data ........................................................................................ 173 Conditional breakpoints....................................................................... 174 Using watchpoints ................................................................................ 174 Pausing programs ................................................................................. 175 16 THE VISUAL COMPONENT LIBRARy ................................................. 176 Introduction.......................................................................................... 176 The Win32 page ................................................................................... 177 The System page .................................................................................. 178 The Internet page .................................................................................. 179 The Data Access page .......................................................................... 179 Data Controls page ............................................................................... 180 The Dialogs page .................................................................................. 181 The Win 3.1 page ................................................................................. 182 INDEX ......................................................................................................... 188

Description:
Delphi 3 is a true object oriented, visual programming environment. If you need to write complex applications for Windows 95, Delphi is an excellent choice. Many professional developers considered that the user interface and the facilities that Delphi 2.0 offers were superior to any other programmin
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.