You can use the component TTimer
.
Add it to the form;
seven your property Enable
for false
.
Enter a relative time for the form to be displayed, approximately 2 seconds = 2000 thousandths in the property Interval
;
The default value of this property is 1000 (1000 thousandths of a second = 1 second). Changing to 2000 will be two seconds.
In the last line of the method OnShow
of the form, seven property Enable
for true
:
Example:
timer1.Enable := true;
Now you need to pass your commands to the event OnTimer
of the component TTimer
. To do this, double-click on the component that will then be created the default method OnTimer
.
Change your commands that are on OnShow
form for that new
method created.
Ready!
After the given time, such as 2 seconds, the commands will start to be executed.
Details about the component TTimer
:
The component TTimer
has an event called OnTimer
which is the main resource of that component and is what has been described in that response to be used.
But, the component TTimer
does not perform this method only once, but rather indeterminate times, from time to time, at intervals defined by the time value set in its property Interval
.
Therefore, to have the method run only once you need to disable it right when running for the first time, thus:
// assinatura fictícia do método / exemplo
procedure FormFicticio.Timer1OnTimer(Sender: TObject);
begin
Timer1.Enable := false; // <-- isso deve ser feito
// Os demais comandos que deseja executar
end;
Doing this he will run only once.
Otherwise it will always execute, as already mentioned.
Got it, Rs. Solved.
– Gabriel Sales