unit main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls
,Windows;
type
{ TForm1 }
TForm1 = class(TForm)
pnl_Speed: TPanel;
shp_Meter: TShape;
Timer1: TTimer;
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure Timer1Timer(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
const
speed_inc = 4;
speed_dwn = 3;
tim = 1/24/60/60;
var
Form1: TForm1;
be_wait : tdatetime;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
);
begin
//
Case Key Of
VK_UP : begin
if shp_Meter.Left<pnl_Speed.Width-shp_Meter.Width then
shp_Meter.Left := shp_Meter.Left + speed_inc;
be_wait := now + (tim*1); // 1 second
end;
VK_DOWN : begin
if shp_Meter.Left>0 then
shp_Meter.Left := shp_Meter.Left - speed_inc;
end;
End;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if now>be_wait then
if shp_Meter.Left<=0 then
shp_Meter.Left := 0
else
shp_Meter.Left := shp_Meter.Left - speed_dwn;
if shp_Meter.Left>=pnl_Speed.Width then
shp_Meter.Left := pnl_Speed.Width-shp_Meter.Width;
end;
end.