Essential Delphi – Copyright 1996-2002 Marco Cantù – 1
Total Page:16
File Type:pdf, Size:1020Kb
Marco Cantù's Essential Delphi – Copyright 1996-2002 Marco Cantù – www.marcocantu.com/edelphi 1 MMARCOARCO CCANTÙANTÙ''SS EESSENTIALSSENTIAL DDELPHIELPHI A Friendly Introductory Guide to Borland Delphi http://www.marcocantu.com/edelphi Copyright 1996-2002 Marco Cantù Revision 1.03 - April 13, 2002 Marco Cantù's Essential Delphi – Copyright 1996-2002 Marco Cantù – www.marcocantu.com/edelphi 2 INTRODUCTION fter the successful publishing of the e-book Essential Pascal (available on my web site at the address http://www.marcocantu.com/epascal), I decided to follow up with an Aintroduction to Delphi. Again most of the material you'll find here was in the first editions of my “printed” book Mastering Delphi, the best selling Delphi book I have written. Due to space constraints and because many Delphi programmers look for more advanced information, in the latest edition this material was completely omitted. To overcome the absence of this information, I have started putting together this second on- line book, titled Essential Delphi. Copyright The text and the source code of this book are copyrighted by Marco Cantù. Of course, you can use the programs and adapt them to your own needs with no limitation, only you are not allowed to use them in books, training material, and other copyrighted formats without my permission (or in case you are using limited portions, referring to the original). Feel free to link your site with this one, but please do not duplicate the material (on your web site, on a CD) as it is subject to frequent changes and updates. Passing a copy to a friend, occasionally, is certainly something you can do if you do not modify it in any way. You can print out this book both for personal use and for non-profit training (user-groups, schools, and universities are free to distribute a printed versions as long as they don’t charge more than the printing costs and make it clear that this material is freely available, referring readers to the Essential Delphi web site (http://www.marcocantu.com/edelphi) for updates. Book Structure The book structure is still under development, as the book evolves. This is the current structure: Chapter 1: A Form is a Window: Chapter 2: Highlights of the Delphi Environment: Chapter 3: The Object Repository and the Delphi Wizards: Chapter 4: A Tour of the Basic Components Chapter 5: Creating and Handling Menus [ some figures still missing ] Chapter 6: Multimedia Fun [ all figures missing ] Planned chapters: Chapter 7: Exploring Forms Chapter 8: Delphi Database 101 Chapter 9: Reporting Basics Marco Cantù's Essential Delphi – Copyright 1996-2002 Marco Cantù – www.marcocantu.com/edelphi 3 Source Code The source code of all the examples mentioned in the book is available on the book web site. The code has the same Copyright as the book: Feel free to use it at will but don't publish it on other documents or site. Links back to this site are welcome. Feedback Please let me know of any errors you find (indicating revision number and page number), but also of topics not clear enough for a beginner. I'll be able to devote time to the project depending also on the feedback I receive. Let me know also which other topics (not covered in Mastering Delphi) you'd like to see here. For reporting errors please use the books section of my newsgroup, as described on www.marcocantu.com or use my mailbox (which gets far too jammed) at [email protected]. Acknowledgments I have first started thinking about on-line publishing after Bruce Eckel's experience with Thinking in Java. I'm a friend of Bruce and think he really did a great job with that book and few others. After the overwhelming response of the "Essential Pascal" book, I started this new one and plan releasing the two as a printed book introducing Delphi (the only problem being to find a publisher). About the Author Marco Cantù lives in Piacenza, Italy. After writing C++ and Object Windows Library books and articles, he delved into Delphi programming. He is the author of the Mastering Delphi book series, published by Sybex, as well as the advanced Delphi Developers Handbook. He writes articles for many magazines, including The Delphi Magazine, speaks at Delphi and Borland conferences around the world, and teaches Delphi classes at basic and advanced levels. More recently, he's specializing in XML technologies, still making most of his programming in Delphi. Of course, you can learn more details about Marco and his work by visiting his web site, www.marcocantu.com. Donations I'll probably set up an account on one of those donation/contribution systems, to let people who have enjoyed the book and learned from it, particularly if programming is their job (and not a hobby) and they do it for profit, contribute to its development. No extra material is offered to those donating to the book fund, only because I want to let anyone (particularly students and people leaving in poor countries) benefit from the availability of this material. Information will be available on the book web site. Marco Cantù's Essential Delphi – Copyright 1996-2002 Marco Cantù – www.marcocantu.com/edelphi 4 Table of Contents Marco Cantù's Essential Delphi.........................................................................................................................................................1 Introduction...............................................................................................................................................................2 Copyright..........................................................................................................................................................2 Book Structure..................................................................................................................................................2 Source Code......................................................................................................................................................3 Feedback...........................................................................................................................................................3 Acknowledgments.............................................................................................................................................3 About the Author..............................................................................................................................................3 Donations..........................................................................................................................................................3 Chapter 1: A Form Is a Window ............................................................................................................................8 Creating Your First Form......................................................................................................................................8 Adding a Title...................................................................................................................................................9 Saving the Form..............................................................................................................................................10 Using Components...............................................................................................................................................10 Changing Properties.............................................................................................................................................11 Responding to Events..........................................................................................................................................13 Compiling and Running a Program.....................................................................................................................16 Changing Properties at Run-Time.......................................................................................................................18 Adding Code to the Program...............................................................................................................................18 A Two-Way Tool.................................................................................................................................................20 Looking at the Source Code...........................................................................................................................20 The Textual Description of the Form.............................................................................................................23 The Project File..............................................................................................................................................25 Using Component Templates.........................................................................................................................26 What’s Next.........................................................................................................................................................26 Chapter 2: Highlights of the Delphi Environment..............................................................................................27 Different Versions of Delphi...............................................................................................................................27 Asking for Help....................................................................................................................................................27