~ Componentes ~
- Timer
- Label
~ Código ~
Declare a Procedure:
Código:
function SToHMS(I: Integer): String;
var
H, M: Integer;
Hs, Ms, Ss: String;
begin
H := I div 3600; //horas completas
I := I mod 3600; //segundos que sobraram das horas completas
M := I div 60; //minutos completos
I := I mod 60; //segundos que sobraram dos minutos completos
if (H < 10) then Hs := '0' + IntToStr(H)
else Hs := IntToStr(H);
if (M < 10) then Ms := '0' + IntToStr(M)
else Ms := IntToStr(M);
if (I < 10) then Ss := '0' + IntToStr(I)
else Ss := IntToStr(I);
Result := Hs + ':' + Ms + ':' + Ss;
end;
No Timer Adcione:
Código:
procedure TForm1.Timer1Timer(Sender: TObject);
var
time: string;
begin
time := SToHMS(GetTickCount div 1000);
label1.caption := time;
end;
Creditos: Bruno Lucatto
Fonte: Planeta Delphi