You can use the TTimer
component.
Add it to form;
seven your property Enable
to false
.
Enter a relative time for the form to be displayed, approximately 2 seconds = 2000 thousandths in the Interval
property;
The default value of this property is 1000 (1000 milliseconds = 1 second). Changing to 2000 will be two seconds.
In the last line of the method OnShow
of the form, the property Enable
to true
:
Example :
timer1.Enable := true;
Now you need to pass your commands to the OnTimer
event of the TTimer
component. To do this, double-click the component that will then create the default method OnTimer
.
Change your commands that are in OnShow
of form to this new
method created.
Ready!
After the given time, like the 2 seconds, the commands will begin to execute.
Details about the component TTimer
:
The component TTimer
has an event called OnTimer
which is the main feature of this component and is what was described in that response to be used.
However, the TTimer
component does not execute this method only once, but rather indeterminate times, from time to time, at time intervals defined by the time value set in its Interval
property.
So, to have the method running only once you need to disable it as soon as you run it for the first time, like this:
// 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 will only run once.
Otherwise it will always execute, as already mentioned.