Fórum Timer #228626
28/04/2004
0
Consegui colocando um TTimer com a propriedade
Interval = 30000
e no evento
OnTimer = ShowMessage(´Tempo esgotado´);
Passados o 30 segundo beleza ele mosta a menssagem, mas quero apresentar num LABEL o tempo restante e caso passe os 30 segundos ele encerre a aplicação.
Como faço?
Wgm8
Curtir tópico
+ 0Posts
28/04/2004
Jowjow
var
TempoTotal: Integer = 0;
...
procedure TForm1.TimerTimer(Sender: TObject);
begin
TempoTotal := TempoTotal + 1;
Label1.Caption := IntToStr(TempoTotal);
if TempoTotal = 30 then
begin
Timer.Enabled := False;
ShowMessage(´O tempo esgotou. O Sistema será encerrado´);
Close;
end;
end;
Gostei + 0
28/04/2004
Jowjow
as propriedades devem estar assim:
Enable = True
Interval = 1000
(*
O q ele faz é executar o evento OnTimer no intervalo de tempo definido em Interval, neste caso a cada segundo. Ok?
*)
Gostei + 0
29/04/2004
Wgm8
var
Cont,i : integer;
begin
cont:=0;
for i := 1 to 30 do
begin
Cont := Cont + 1;
TempoLA.Caption := IntToStr totime(cont);
end;
if Cont = 30 then
begin
Timer1.Enabled := False;
ShowMessage(´O tempo esgotou. O Sistema será encerrado´);
end;
end;
Gostei + 0
29/04/2004
Jowjow
Coloque um label e um Timer no form e faça o teste com uma nova applicação e depois adapte ao seu programa
*)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Label1: TLabel;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
TempoTotal: Integer = 0;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
TempoTotal := TempoTotal + 1;
Label1.Caption := IntToStr(TempoTotal);
if TempoTotal = 60 then
begin
Timer1.Enabled := False;
ShowMessage(´O tempo esgotou. O Sistema será encerrado´);
Close;
end;
end;
end.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)