The ShowMessage window
If the window grows without limit every time the button is pressed, it leaves the screen; a condition must be set. The conditional statement: if Form1.Width < 700 then … else … – if the condition is true the first part runs, if false the part after else runs. To tell the user the reason, ShowMessage('text') is used: it shows a separate small window and the application waits until OK is pressed. Inside a string write only Latin letters and ordinary signs; the Uzbek ‘ sign can be confused with the single quote. To show the window size in the title, the number is converted to text: Form1.Caption := 'Eni: ' + IntToStr(Form1.Width); without IntToStr, 'Eni: ' + Form1.Width is an error, because a number cannot be added to text. Check the condition first and only then change, so that the application does not pass the limit.
In a music app a message “Too loud” appears if the volume goes above a set limit, and nothing appears otherwise. The programmer wrote a condition and tied the message to it. The user then understands why there is a limit.
Mobile app developers, creators of banking apps and game designers show warnings depending on a condition.
Write 3 rules “if …, show … message, otherwise nothing” for an app of your own invention and test each with one number.
1procedure TForm1.Button2Click(Sender: TObject); 2begin 3 if Form1.Width > 300 then 4 begin 5 Form1.Width := Form1.Width - 20; 6 Form1.Height := Form1.Height - 10; 7 end 8 else 9 ShowMessage('Oyna yetarlicha kichik'); 10end;
1Form1.Caption := 'Olcham: ' + IntToStr(Form1.Width) + ' x ' + IntToStr(Form1.Height);“The border guard”: a pair writes the application with the limit set at 500 pixels and calculates in advance at which click the message appears.