Basic Delphi

Introduction

For this tutorial I assume that you are familiar with Pascal. If you are not, read one of the many Turbo Pascal tutorials first (search for "pascal tutorial" in Yahoo). It also helps to know the concepts of object oriented programing (OOP), but I'll briefly explain this.

Please excuse all the typos and other faults. English is not my native language.

Delphi

Delphi is a so called RAD-Tool (RAD stands for Rapid Application Development). It allows you to visually design (by using drag-and-drop) dialog and even whole applications. In the toolbar of the main window you can find a lot of predifined conponents to use on your projects. Simple double-click on the icons to paste them into the active form. On the left hand side of your screen is the object inspector. You can set properties for your components. There is no need to write source code for this! A good way to learn Delphi is to play around with the components.

back to top

A first example

  1. Choose File - New Application
    This will create a empty form to which you can add all the components you want.
  2. You can now add components from the component palette by double-clicking on them. To change their size select them, click on one of the corners and move the mouse.
    As a first step add a button (sixth from the left in the "standard" palette). It'll be in the middle of the form. Move it any place you want. The button will have "button1" written on it which is not very usefull for your program. To change the text on the button (it is called caption), go to the object inspector and change the "Caption" field.
  3. Now the user could click on the button in your program, but nothing would happen. To assign any actions to the button double-click on it. Delphi brings up the source code window. The cursor is already in the correct position.
  4. You can put any pascal code in the procedure. For this example simply type "close;". This closes the form and terminates the application.
  5. Your project is now ready to be compiled. Choose File - Save As to save it. I recommend you use different directories for all your projects because they tend to have many files (at least 5).
  6. To compile and execute the project click on the "play" button in the toolbar.
  7. You will see a window that can be resized and moved around the normal "windows" way. You can close it by either clicking your button, clicking on the "close"-button in the top right corner, or selecting close from the window menu (top left corner).

back to top

StartSecond Day
Back to tutorial main page.


Please e-mail me with any comments!
© 27.12.96 Sebastian Boßung Home