You are on page 1of 2

unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, RXClock;

type TForm1 = class(TForm) Button1: TButton; Timer1: TTimer; RxClock1: TRxClock; procedure Button1Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; lig : integer = 0; implementation {$R *.DFM} function SetNewTime(Hora, Min, Seg: word): boolean; var st: TSYSTEMTIME; begin GetLocalTime(st); // Pega hora corrente st.wHour := Hora; st.wMinute := Min; st.wSecond := seg; if not SetLocalTime(st) then Result := FALSE else Result := true; end; procedure TForm1.Timer1Timer(Sender: TObject); var Present: TDateTime; Hour, Min, Sec, MSec: word; hh, mm, ss : shortstring; begin Present:= Now; DecodeTime(Present, Hour, Min, Sec, MSec); sec := sec - 1; // mantem o relogio parado entre um segundo e outro hh := IntToStr(hour); mm := IntToStr(min); ss := IntToStr(sec); SetNewTime(StrToInt(hh),StrToInt(mm),StrToInt(ss)); end;

procedure TForm1.Button1Click(Sender: TObject); begin lig := lig + 1; if lig = 1 then Timer1.Enabled := true else begin Timer1.Enabled := false; lig := 0; end; end;

end.

You might also like