unit uProg3;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Elkap: TButton;
    Idozito: TTimer;
    procedure IdozitoTimer(Sender: TObject);
    procedure ElkapClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.IdozitoTimer(Sender: TObject);
Var rx,ry:Integer;
begin
     rx := random(2);
     if rx=0 then rx := -1;
     rx := rx * 10;
     ry := random(2);
     if ry=0 then ry := -1;
     ry := ry * 10;
     If (Elkap.Left + rx >= 0) And
        (Elkap.Left+Elkap.Width+rx <= ClientWidth) Then
     Elkap.Left := Elkap.Left + rx;
     If (Elkap.Top + ry >= 0) And
        (Elkap.Top+Elkap.Height+ry <= ClientHeight) Then
     Elkap.Top := Elkap.Top + ry;
end;

procedure TForm1.ElkapClick(Sender: TObject);
begin
     Idozito.Enabled := Not Idozito.Enabled;
end;

end.
