Компоненты: TTimer и TBitBtn
Обработка события OnClick кнопки TBitBtn
var
Form1: TForm1;
a,b:integer;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if a=1 then begin
timer1.Interval:=1;
a:=2;
BitBtn1.Caption:='Слови меня =))';
end
else
begin
timer1.Interval:=0;
a:=1;
BitBtn1.Caption:='Словил =))';
end;
end;
Обработка компонента TTimer:
procedure TForm1.Timer1Timer(Sender: TObject); begin if BitBtn1.Left=form1.Width-76 then b:=1 else if BitBtn1.Left=0 then b:=2; if b=1 then BitBtn1.left:=BitBtn1.left-1 else if b=2 then BitBtn1.left:=BitBtn1.left+1; end; procedure TForm1.FormCreate(Sender: TObject); begin a:=1;b:=2; timer1.Interval:=0; end; end.
Смешной код 🙂