At the first boot, a blank form (Form1) opens. You can see the properties of Form1 in the Object Inspector on the left. This form is our main form (for now). You can think of the form as an object carrier. You can move the left of this form to the desired size by tapping left. If we run the program by pressing karşılaş RUN kısm (green right arrow button) or F9, we will see an empty form (window) at the top of it.


Press the atı X ”button to review the windows buttons at the top of Form1, then close the program and return to the delphi environment.


Works with Delphi objects. So we have a number of ready-made objects (objects), we put together these objects appropriately and write our programs. Trowel, hammer, concrete, iron, water, door, window, M. they are all objects. We can make a house by bringing these objects together according to our purpose. Here is how to write programs with delphi.


Delphi objects palette (Camponent palette)


Delphi objects in general: TForm, TEdit, TLabel, TButton, TMemo, TPanel, TComboBox, TListBox, d ..

Each object has a number of properties. These features can be divided into 2 groups;

  1. Design time properties
  2. (Dynamic) properties that can only be edited during program execution (run time properties)

a) Events at work

b) Other features


All features that can be edited at the design stage can also be edited at runtime. All features in the design phase are available in the Object Inspector-Properties tab.


Please check the design features of Form1. Observe changes in Form1 by changing the values ​​of these properties. You must click the Object Inpector-Events tab to view events that occur at runtime. In this section you will see that there is no value against the events. You must encode the works that you want to do when these events happen (for some time now, wait a little).


The Object Inspector window reflects its properties, which object is selected. You can read which object is selected at the top of this window.


Delphi's Code Structure


The Delphi codes are modular (code snippets). You might think like Lego pieces. Each module can have sub-modules. These modular structures are called Procedure or Function. When you write a code snippet, you must give a name using one of these two statements.


Procedure Toplama(x, y,z:Integer);
Begin
z:=x+y;
……….
end;


or


Function Toplama(x, y, z:Integer):Integer;
Begin
z:=x+y;
………
end;


Like. All the Codes Begin... End  In the range, each line of code that makes the employee must end with ";".


To change the properties attached to an object, to run the procedure or functions, we write them by combining them with ".".


Form1.Caption:=”Delphi öğreniyorum”
Form1.Toplama(2,4)
Form1.Edit1.Font.Color.=clRed


": =" is used when assigning a value to a variable or a property.


When calling the Submodule B of an A module, only

B; 

you just need to type.

To recall C, which is the sub-module of module B when in module A

B.C;


you need to write.


Delphi Code Window


If you double-click on Form1, the code window will appear. You will see takım Unit1.Pas if on the window and you'll see a number of expressions inside the window. The double-click procedure is the defined event of that object. The FormCreate event of Form1 is the default event. We need to code the works that we want to do when creating this form.




For example, the form's size, color, how to open ren.




For each added form, a new code file (extension) is created with the extension yeni .pas Her. The first form is the main form (you can change it later if you wish). The first form's code will run when your program runs.




Now click the Events tab from Object Inspector, and then click on the On Click feature and double-click.




Begin ... End; If you write ait Form1. 1 and wait for a few seconds,




window with information such as the types of these properties and the values ​​to be obtained.

Form1.color:=clRed; 

code.


Unit:  The name of the code fragment. Here are the codes of Form1. Since it is not yet saved, it appears as ”Unit1 Henüz.

Interface: Indicates that the interface of the program has started

Uses: Shows the code libraries of objects to be used in this program. In other words, they are tool rooms.

Type: Defines the objects, procedures and functions to be used in the program.


TForm1=Class(TForm) : TForm 

to create the object as TForm1 for this program.




Immediately below this is the procedure under TForm1.




Private: Other objects, procedures that TForm1 objects that are linked to TForm1 can be used.




Public: Objects, procedures and other forms of TForm1 can be used.




Yes: This section describes the global variables of TForm1. TForm1, the same as TForm




is a virtual object. Objects are not used directly in the program. Instead, it is transferred to the variable. Because the same object can be used elsewhere (such as taking a picture of an object, you can take as many photos as you want, the object stops where it stops). The TForm1 object is passed to the Form1 variable. All processes are handled with this Form1. The name of the bearer of all objects connected to this form is Form1. Changes to Form1 are transferred to the TForm1 object.




Implemantation: Indicates that the program codes have started.




{$ R, * .DFM}:


Shows how to compile the program.




Unit1 ends with dotted end bit end. Unit.




We created FormCreate and FormClick procedures of TForm1. Because the FormCreate procedure contains no code, it will be deleted during the compilation. FormClick proceduru will automatically activate when clicked on the form and execute the codes it hosts. The expression TObject: Sender in parentheses is a statement that delphi has added to itself, so that the active object is understood.




Now, press the green right arrow button or F9 ′ to run the pogram.




If you click Form1 when the program runs, you will see Form1 turning red. Close the program (by pressing the X button in the upper right corner of Form1) and return to the delphi environment.




From the Project menu, click Options and open the Application tab.




In Title, type anything you want, select icon (icon in the Borland Shared-Images folder under the folder where you are loading delphiyi) and click OK. From the File menu, click SaveAll and save our program. The codes of each form opened must be saved as a separate file. After saving all forms, let us give a name to the project that contains all forms.




Press the al RUN ızı button and run the program again. You should see the icon and name of your program in the taskbar. Close the program and the delph. Open the folder where you saved your project. There you will see the exe of your program created and you will be happy. Now you can run it by double clicking on it.