How to make "loading" progress in Pascal? From 1% to 100% for a certain period of time. That is, during this time 1% is replaced by 2% and so on to 100.

  • Use timer , which after a specified period of time will change the value of the progress bar . - slippyk

1 answer 1

The simplest example in Lazarus

 procedure TForm1.FormCreate(Sender: TObject); begin // Задаем интервал в полсекунды Timer1.Interval:= 500; // Запускаем таймер сразу после загрузки главной формы Timer1.Enabled := True; end; procedure TForm1.Timer1Timer(Sender: TObject); begin // Увеличиваем прогресс на 2 через каждые полсекунды ProgressBar1.Position := ProgressBar1.Position + 2; if ProgressBar1.Position = 100 then begin // После 100% прогресса останавливаем таймер Timer1.Enabled := False; ShowMessage('Timer stopped'); end; end;