Fórum Problema com cronômetro regressivo quando uma form é ativada #370429
13/05/2009
0
Parte do código
-------------------
procedure TForm1.Timer1Timer(Sender: TObject);
begin
maxtime := (maxtime- strtotime(´00:00:01´));
label1.Caption := timetostr(maxtime);
if TimeToStr(maxtime) = ´00:00:00´ then //se o cronometro zerar
begin
timer1.Enabled := false; //o timer fica desabilitado
Form2.Visible:= true; // a form secundária aparece
Form1.Visible:= false; //e a form ´principal some
if Form2.Visible= true then //se a form secundária estiver visivel o timer fica desabilidado
timer1.Enabled := false;
if Form1.Visible= true then begin //se o form principal estiver visivel ele volta a contar apartir da escolha feita anteriormente na combobox {aqui está o problema. quando a form secundária fecha e a form principal volta, o cronômetro fica estagnado no ´00:00:00´, parado}
timer1.Enabled := true;
cont:=0;
Label2.Caption:= ´0´;
case combobox1.itemindex of
0: maxtime := strtotime(´00:01:00´);
1: maxtime := strtotime(´00:02:00´);
2: maxtime := strtotime(´00:03:00´);
end;
end;
-----------------------
-----------------------
código da Form Secundária
-----------
procedure TForm2.Timer1Timer(Sender: TObject);
begin
if form1.visible = false and form2.Visible = true then begin
maxtime2 := (maxtime2 - strtotime(´00:00:01´));
label2.Caption := timetostr(maxtime2);
if TimeToStr(maxtime2) = ´00:00:00´ then begin
timer1.Enabled := false;
form2.Close;
form1.visible:=true;
end;
end;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
maskedit1.text:=´00:00:30´;
maxtime2:= strtotime(maskedit1.text);
timer1.Enabled := true;
label2.Caption := timetostr(maxtime2);
end;
end.
----------------------------------
De antemão, agradeço qualquer ajuda!!! :)
Pfloyd_fan
Curtir tópico
+ 0Posts
14/05/2009
Woinch
Espero ter ajudado.
Gostei + 0
15/05/2009
Pfloyd_fan
vou tentar aqui. Quem tiver mais alguma sugestão ou ajuda, será sempre bem vinda!!!
Abraços!!! o/
Gostei + 0
19/05/2009
Pfloyd_fan
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)