Visual Programming Concept
In this tutorial, we’re going to learn about basic visual programming concept. We’re going to learn how to create a form including several components.
There are three steps of visual programming : Creating a user interface, Writing codes and Compiling code and form into an executable file (.EXE). When you run the program,
Creating a simple project
To create a project, first you must create a user interface. Resize the blank form into a desired size you like (you have to find out how to resize the form yourself). Set form properties like table shown below :
Caption | My First Delphi Project |
Name | MyForm |
Position | poDesktopCenter |
Add a label component, it is in Standard page of component palette. Set label properties like table shown below :
Caption | This is my first Delphi project |
Add a button component, it is also in Standard page of component palette. Set button properties like table shown below :
Caption | &Exit |
Name | ExitButton |
Now, we have a user interface below :
Adding codes for ExitButton
If you want to add some codes to ExitButton, you have to determine the event when the codes will be executed. Then you can write some codes for the event. In this case you have to write some codes for OnClick event of the ExitButton. From the event tab of object inspector, select or double click the OnClick event (see the picture).
Start writing the codes :
procedure TMyForm.ExitButtonClick(Sender: TObject)
begin
Application.Terminate;
end;
You only have to type a simple code : Application.Terminate; You have to put the(;) after the statement. This code will end your application.
0 comments:
Post a Comment