☰ Contents · Computing

The application window

Lessons 37–38 · 2 lessons · N. I. Taylaqov (general editor), A. B. Akhmedov, M. D. Pardayeva, A. A. Abdug‘aniyev, U. M. Mirsanov. Informatics and Information Technologies, Grade 10, 1st edition. “Extremum-Press”, Tashkent, 2017
37

An application and its window

Textbook: pp. 86–89
GoalSets the Width, Height, Left, Top, Caption and Color properties of the application window, runs the application with F9 and saves it.
New words
Width / Height: the width and height of an object in pixels · Width / HeightLeft / Top: the distance from the left and the top edge of the screen (or parent) · Left / TopCaption: the title text of a window or control · Captionpixel: one dot of the screen, the unit for sizes in Delphi · piksel
Explanation

The application window is the object Form1, and it has more than 50 properties. The main ones are Width and Height – in pixels; Left and Top – the distance of the window from the left and top edges of the screen; Caption – the title text; Color – the background colour. A property can be changed in two ways: select the window and type the value in the Object Inspector, or drag the lower right corner of the window. The written form is “object.property := value;”, for example Form1.Width := 400; and Form1.Caption := 'My first app'; (text in single quotes). Colour names begin with cl: clAqua, clYellow, clWhite. To see the changes, run the application from the Run menu, with the green triangle on the toolbar or with F9; to stop it, press the close button of the window.

Worked examples
Form1.Width := 400; Form1.Height := 300; – the window is 400×300 pixels. With Form1.Left := 100; Form1.Top := 50; the right edge of the window is 100+400 = 500 pixels from the left edge of the screen and the bottom edge is 50+300 = 350 pixels from the top.
Form1.Caption := 'Salom'; makes the title “Salom” and Form1.Color := clAqua; makes the background light blue. Text values are written in single quotes and colour names without quotes. Upper or lower case does not matter to Delphi, but names are written as Delphi writes them to keep them easy to read.
Class activity

“The window workshop”: each student makes the window 450×300, writes a nickname in the title, changes the colour and runs it with F9 to check where on the screen it sits.

Practice
1
Which property stores the width of the window?
2
If Left = 120 and Width = 380, how many pixels is the right edge of the window from the left edge of the screen?
3
Write two of the three ways of running an application.
4
Why is Caption text written inside single quotes?