unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
StdCtrls, Buttons, ExtCtrls, ComCtrls, Math;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
TrackBar1: TTrackBar;
BlinkTimer: TTimer;
Edit1: TEdit;
Edit2: TEdit;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure BlinkTimerTimer(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Edit2Change(Sender: TObject);
private
{ Private-Deklarationen }
fin, trackbarzeit: Double;
isSliding: Boolean;
checktime, is_checktime, counter: TTime;
checkfin:Double;
endpos: Integer;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Caption:= 'Eingabe Zeit in sec+millisec';
Label2.Caption:= 'Eingabe Endpos';
Button1.Caption:= 'Start';
Edit1.Text:='10,000'; //Zeit Vorgabe in sec und millisec
Edit2.Text:= '10'; //Zielposition des Sliders
fin:= 10.000;
endpos:= 10;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
checkfin:= 0;
//---------------//
trackbarzeit:= RoundTo((fin /(70-endpos)), -3);
//---------------//
Label3.Caption:= floattostr(trackbarzeit);
TrackBar1.Position:= 70;
issliding:= True;
checktime:= Now;
counter:= Now;
end;
procedure TForm1.BlinkTimerTimer(Sender: TObject);
begin
Label4.Caption:= FormatDateTime('hh:nn:ss:zzz', Now- counter);
if isSliding then
begin
is_checktime:= roundto(((Now- checktime) * 100000),-3);
Label5.Caption := TimeToStr(is_checktime);
if is_checktime > (trackbarzeit) then
begin
Label6.Caption:= FormatDateTime('hh:nn:ss:zzz', now- counter);
checkfin:= checkfin+is_checktime;
Label7.Caption:= FloatToStr(checkfin);
TrackBar1.Position:=TrackBar1.Position -1;
if checkfin >= fin then isSliding:= False;
checktime:= Now;
end;
end;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
if Edit1.Text <>'' then
fin:= StrToFloat(Edit1.Text);
end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
if Edit2.Text <>'' then
endpos:= StrToInt(Edit2.Text);
end;
end.