When the first time you run Delphi, display that appears more or less are as follows:

First appearance of Delphi XE4
First appearance of Delphi XE4

First appearance of Delphi 6
First appearance of Delphi 6


Form is the display of the program that you created. Try to run the program by pressing the F9 key. You will see a program window which is still empty. Of course still empty because you have not added any to them. However, the program has had a behavior as most Windows programs. You can shift its position, modify its size, does minimize, maximize, restore, and close the program by clicking on the cross button on the top right corner of the window. If we use the XE4, the first time we are running Delphi, there has been no application made, so we haven’t been able to run the application by pressing F9. Make in advance by clicking on the menu File>New>VCL Forms Application – Delphi.

Change the appearance of the Form

The Form is an object of the program. Each object of the program has its own behavior. To change the behavior of the object of the program, we can do it through the window of the Object Inspector. This window usually found at the bottom left corner, but if this window is not visible, it can be displayed by pressing the F11.

There are two tabs in the Object Inspector window, Properties and Events. Easily, the properties of the object the program will determine the appearance of the object. While the event will determine how the object will act and react. Actually this explanation is not exactly like so, yet until this step please just consider like so.

The properties that are most important from a Form (or perhaps other program objects) ie are:

  • Name

    Each object has a name. This is the property that will be very useful for reference in the program. This property must be unique for the entire objects in the program. So, there is no single program object that has a name equal to the other object. By default, the name of the first Form object is Form1.

  • Caption

    Caption is the title of the program object. If the object is a Form, then the caption is the text that appears in the Title Bar. If the object is a button, then the caption is the text on the button. By default, the caption will contain the same as the name of the object. Try to change this property to ‘First Program’ . If you press the F9 key, then Your program display will be as follows:

    Appearance of First Program (XE4)
    Appearance of First Program (XE4)

    Appearance of First Program (Delphi 6)
    Appearance of First Program (Delphi 6)

  • Width and Height

    Width and Height are the size of the program object. You can make changes to the property by way of drag on an object or enter a value for this property of the Object Inspector window.

  • Color

    By default this property will contain clBtnFace ie the buttons colours which is automatically changes according to the settings on the Display Properties of Windows. You can fill it with system colors which are the colors that will changes according to the Display Properties, or may with static colors that will always remain even though the Display Properties changes.

Add the program object into the Form

You can add objects of the program into the Form with any object you like as much as you like. Of course the reasoning does not like or don’t like but more in consideration of the needs of the program.


One of the most important program object is Button. To add object Button into the Form, click the Button component in the Component Palette. After that component appear selected, click on the desired position on the Form and drag to define its size.

Choose TButton to be added to the Form
Choose TButton to be added to the Form

The object of the first Button will automatically be named Button1 with a caption equal with its name. You can change the name or caption property via the Object Ispector. But for now, we don’t need to put much concerns in changing its properties.

As we have discussed above, in addition to the properties, the object has an event, how the object act and react. One of the most important event of the object with the type of TButton is OnClick event, i.e. actions committed by the program if a Button object is clicked. You can fill these events and see what event is owned by a Button through the Object Inspector. But to simply populate the event OnClick of a Button, you can simply double-click on the Button object.

If you double click on a Button object, then you will be taken to the code editor to the event OnClick of the Button object as follows:

procedure TForm1.Button1Click(Sender: TObject);

The code for the event is still empty. Now try to add a code into it so that the event is as follows:

procedure TForm1.Button1Click(Sender: TObject);

Run the program by pressing the F9 key. The first time the program is run, then it looks more or less are as follows (depending on the size and position you created):

The first Program with Button
The first Program with Button

If you click on the button, then the text on the button will change.

The first Program after the Button is clicked
The first Program after the Button is clicked

The process that occurs is as follows:

If the button is clicked, then the procedures linked to the event OnClick of the button will be executed. In this case the procedure is procedure TForm1.Button1Click in which there is a command to change the caption property of Button1.


To refer to a property of an object, first, write the name of the object, followed by a dot, and then followed by the name of its property. So to refer to the caption property from the button object named Button1, then we write it as Button1.Caption.

Assignment Operator

The Assignment Operator is an operator that serves to fill the object on the left side of the sign with the object on the right sign. The Assignment Operator in mathematics is the equal sign (=), but Delphi using colon equals (:=). Between the colon and equal sign must not be separated.


String type is a string of characters. Writing strings in Delphi must be enclosed with single quotation marks (use quotation marks that are the same button with double quotation, not quotation marks which are to the left of the 1 key).

Now we can understand the meaning of


as command to populate the property caption (which is a string of characters) of the Button1 object with the string (character string) ‘Clicked’.


Semicolon is used to indicate the end of the program statement. A program statement can be divided into several lines. As long as semicolon is not yet found, then the lines are still regarded as one statement of the program.


The Label is a component that serves to display the information in the form of a string. Add this component into the Form below Button1 so it looks like the following figure:

The addition of the Label below the Button
The addition of the Label below the Button

The object name of the first label is Label1 automatically, as well as the captionnya property.

Now, change the command line:




Run the program and click on the button. What is changed is the text below the button, not the text on the button.

Data type

If we are talking about the program, it cannot be separated from discussion about data types. Basically, there are two kinds of simple and fundamental data types, i.e, the numeric and character type. Numeric type are further divided into several groups. Likewise with character type.

The Data in the program is stored in a storage medium that is called with the variable. Variable with the numeric data type can only receive data in the form of numbers. Similarly, a variable with a type character can only receive data in the form of characters. The more important difference is that the type of numeric can be used for arithmetic operations, while the type karaktier can not. The classification of data types such as this is not a grouping of data types according to the definition of Delphi, but grouping like this is just the way I am merely to simplify the discussion. Gradually, we will improve understanding of the data type.

Details about the data types are as follows:

Numeric data type

There are two kinds of numeric data type i.e. integers and fractional.

Integer Type

Data typeRangeSize
Fractional type

Data typeRangeSignificant DigitSize (byte)
Real482.9 x 10^–39 .. 1.7 x 10^3811–126
Single1.5 x 10^–45 .. 3.4 x 10^387–84
Double5.0 x 10^–324 .. 1.7 x 10^30815–168
Extended3.6 x 10^–4951 .. 1.1 x 10^493219–2010
Comp–2^63+1 .. 2^63 –119–208
Currency–922337203685477.5808.. 922337203685477.580719–208

The Division of the various data types used to gain efficiency. For example, if we are going to keep track of the day in a month that the maximum is 31 days, then we can use the byte data type has a range of 0 .. 255. Although we can use the integer type, but the use of an integer is a waste because the integer takes 32 bits (4 bytes) of memory, while byte requiring only 8 bit.

The assignment between two variable with a different data type will cause the following things:

  • Fractional type can be assigned by the integer type, but not vice versa.
  • Type with greater range could be assigned by a smaller range of types without any problem. However, if a type with a smaller range is assigned by the type that has a greater range, then the data will be truncated which will produce calculations that might be wrong.

Characters type

The Data with character type is the data that saves the character from a. ..z, a..Z, 0 .. 9, as well as all the character found on the keyboard. The characters actually also has the ordinal value starts from 0 to 255. It is therefore a character type of data has the same size with byte type. Strings as we have used in the experiment with the caption is a string of characters.

In addition to the types as already mentioned above, there are a lot of another data types. In fact we can also make our own data type.


Above already mentioned that in order to save the data, we need the storage medium are called variables. Before we can use a variable, first we have to declare it. To declare a variable, we need a keyword var followed by the name of variabelnya, followed by a colon, followed by the type of data, then closed with a semicolon.

The addition of keywords var only needed once as long as there is no other keywords added.

The Program we have created has had a variable with the name of Form1 has the data type TForm1. If we see in the code editor, the complete listing is as follows (XE4):

unit Unit1;


  Winapi.Windows, Winapi.Messages, System.SysUtils,
  System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    { Private declarations }
    { Public declarations }

  Form1: TForm1;


{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);


TForm1 is data type that we make ourselves. But the creation is done automatically by Delphi in accordance with the arrangements we do.

Experiment of variables

On the first program that we make, the first time the program is executed, text that appear below the button is ‘Label1’. After the button is clicked, the text changed into ‘Clicked’. We will try to create a program with a different action. The first time the program is run, the text bellow the button is number zero. Every time button is clicked, the number bellow the button will go up.

Reopen the first Program, and then change the caption property of Button1 to ‘Up’ and caption of Label1 to ‘0’. Create a variable named Number with data type of integer. How to do this is by adding the line below Form1 declarations as follows:

   Form1: TForm1;  
   Number: integer;

After that, change the procedure TForm1.Button1Click to become as follows:

procedure TForm1.Button1Click(Sender: TObject);

3 thoughts on “Getting Started – Delphi

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

Notify me of followup comments via e-mail. You can also subscribe without commenting.