An application and its window
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.
| Property | Meaning |
|---|---|
| Width, Height | width and height (pixels) |
| Left, Top | distance from the left and top edges of the screen |
| Caption | title text |
| Color | background colour |
Every time a learning app opens, its window appears in the middle of the screen with the title “Lesson”. The programmer set this by giving values to the window’s size, position and title properties. Change a value and the window changes too.
App developers, interface designers and game makers control the size and position of windows and buttons with values.
On paper draw a rectangle as a screen, put 3 “windows” of different sizes inside it, and show for each the distance from the left and from the top with arrows from the corner.
| Property | Value | Meaning |
|---|---|---|
| Left | 100 | from the left edge |
| Top | 50 | from the top edge |
| Width | 400 | width |
| Height | 300 | height |
“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.