unit uProg3;

interface

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

type
  TfGomb = class(TForm)
    bGomb: TButton;
    tIdozito: TTimer;
    procedure tIdozitoTimer(Sender: TObject);
    procedure bGombClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fGomb: TfGomb;

implementation

{$R *.DFM}

procedure TfGomb.tIdozitoTimer(Sender: TObject);
Var rx,ry:Integer;
begin
     rx := (1-random(3))*10;
     ry := (1-random(3))*10;
     if (bGomb.Left + rx >= 0) And
        (bGomb.Left + bGomb.Width + rx <= ClientWidth) Then
        bGomb.Left := bGomb.Left + rx;
     if (bGomb.Top + ry >= 0) And
        (bGomb.Top + bGomb.Height + ry <= ClientHeight) Then
        bGomb.Top := bGomb.Top + ry;
end;

procedure TfGomb.bGombClick(Sender: TObject);
begin
     tIdozito.Enabled := Not tIdozito.Enabled;
end;

end.
