Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Timer con ProgressBar (https://www.clubdelphi.com/foros/showthread.php?t=69911)

radenf 17-09-2010 17:19:14

Timer con ProgressBar
 
Hola amigos:

Durante varios dias me estuve quebrando la cabeza para realizar una cuenta regresiva o progresiva, para ejecutar una acción con un Timer y un ProgressBar y al fin lo conseguí. Como he visto que en el foro este es un tema de consulta frecuente, les adjunto el código por si a alguien le puede servir en sus proyectos.

Colocar en el Form un Timer y un ProgressBar

Cuenta progresiva

Código Delphi [-]
procedure Form1.FormCreate(Sender: TObject);
begin
Timer1.Interval := 3000;
ProgressBar1.Min := 0;
ProgressBar1.Position := ProgressBar1.Min;
Timer1.Enabled := true;
end;

Código Delphi [-]
procedure Form1.Timer1Timer(Sender: TObject);
begin
ProgressBar1.StepBy(1) ;
if ProgressBar1.Position = 100 then
begin
Acción que desees realizar;
Timer1.Enabled:= False;
Timer1.Interval := 3000;
ProgressBar1.Min := 0; 
ProgressBar1.Position := ProgressBar1.Min;
Timer1.Enabled := true;
end;
end;

Cuenta regresiva

Código Delphi [-]
procedure Form1.FormCreate(Sender: TObject);
begin
Timer1.Interval := 500;
ProgressBar1.Max := 600;
ProgressBar1.Position := ProgressBar1.Max;
Timer1.Enabled := true;
end;

Código Delphi [-]
procedure Form1.Timer1Timer(Sender: TObject);
begin
ProgressBar1.StepBy(-1) ;
if ProgressBar1.Position = 100 then
begin
Acción que desees realizar;
Timer1.Enabled:= False;
Timer1.Interval := 500;
ProgressBar1.Max := 600; 
ProgressBar1.Position := ProgressBar1.Max;
Timer1.Enabled := true;
end;
end;

En ambos casos el Timer funcionará por 5 minutos y se reiniciará.

Saludos y ojalá que a alguien le sirva

marcoszorrilla 18-09-2010 14:36:25

Muchas gracias por la aportación a los Foros.

Un Saludo.

Caral 18-09-2010 15:13:35

Hola
Pues si, muy interesante, gracias por el aporte.
Saludos


La franja horaria es GMT +2. Ahora son las 21:27:21.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi