Aqui el codigo:
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Buttons; type TCrono = class(TForm) Timer1: TTimer; Panel1: TPanel; Panel2: TPanel; Panel3: TPanel; Hinicio: TLabel; RCuenta: TLabel; Panel4: TPanel; Panel5: TPanel; Panel6: TPanel; Iniciar: TBitBtn; Pausa: TBitBtn; Detener: TBitBtn; Reset: TBitBtn; Salir: TBitBtn; procedure Timer1Timer(Sender: TObject); procedure FormShow(Sender: TObject); procedure IniciarClick(Sender: TObject); procedure PausaClick(Sender: TObject); procedure DetenerClick(Sender: TObject); procedure ResetClick(Sender: TObject); procedure SalirClick(Sender: TObject); private { Private declarations } horaInicio, marca: TDateTime; procedure LimpiaDisplay; public { Public declarations } end; var Crono: TCrono; implementation {$R *.dfm} procedure TCrono.LimpiaDisplay ; begin Hinicio.Caption := '00:00:00:000'; RCuenta.Caption := '00:00:00:000'; end; procedure TCrono.FormShow(Sender: TObject); begin Reset.Enabled := False; Detener.Enabled := False; Pausa.Enabled := False; LimpiaDisplay; end; procedure TCrono.Timer1Timer(Sender: TObject); var marca: TDateTime; begin marca := Time; RCuenta.Caption := FormatDateTime('hh:nn:ss:zzz',marca - horainicio); end; procedure TCrono.IniciarClick(Sender: TObject); var marca: TDateTime; begin Iniciar.Enabled := False; Detener.Enabled := True; Pausa.Enabled := True; Reset.Enabled := True; horaInicio := Time; marca := Time; Hinicio.Caption := FormatDateTime('hh:nn:ss:zzz',horaInicio); RCuenta.Caption := FormatDateTime('hh:nn:ss:zzz',marca - horainicio); Timer1.Enabled := true; end; procedure TCrono.PausaClick(Sender: TObject); begin if Pausa.Caption = 'Continua' then begin Timer1.Enabled := True; Pausa.Caption := 'Pausa'; end else begin Timer1.Enabled := False; Pausa.Caption := 'Continua'; end; end; procedure TCrono.DetenerClick(Sender: TObject); begin Timer1.Enabled := False; Iniciar.Enabled := False; Pausa.Enabled := False; Detener.Enabled := False; end; procedure TCrono.ResetClick(Sender: TObject); begin if Timer1.Enabled then Timer1.Enabled := False; LimpiaDisplay; Iniciar.Enabled := True; end; procedure TCrono.SalirClick(Sender: TObject); begin Close; end; end.
Espero lo disfruten:
Un Saludo.