
14.07.2013, 21:51
|
 |
Гуру
|
|
Регистрация: 09.03.2009
Адрес: На курорте, из окна вижу теплое Баренцево море. Бррр.
Сообщения: 4,723
Репутация: 52347
|
|
Код:
unit Unit13;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Spin;
type
TForm13 = class(TForm)
SpinEdit1: TSpinEdit;
SpinEdit2: TSpinEdit;
Label1: TLabel;
Label2: TLabel;
Timer1: TTimer;
Button1: TButton;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
ArrShape: Array of TShape;
public
{ Public declarations }
end;
var
Form13: TForm13;
implementation
{$R *.dfm}
procedure TForm13.Button1Click(Sender: TObject);
begin
SetLength(ArrShape, SpinEdit1.Value - 1);
Timer1.Interval := SpinEdit2.Value * 1000;
if Button1.Caption = 'Start'
then Button1.Caption := 'Stop'
else Button1.Caption := 'Start';
Timer1.Enabled := Button1.Caption = 'Stop';
end;
procedure TForm13.Timer1Timer(Sender: TObject);
var
i: Integer;
begin
Randomize;
for i := 0 to Length(ArrShape) - 1
do begin
if not Assigned(ArrShape[i])
then begin
ArrShape[i] := TShape.Create(Self);
ArrShape[i].Parent := Self;
ArrShape[i].Shape := stSquare;
ArrShape[i].Width := 10 + Random(100);
ArrShape[i].Height := ArrShape[i].Width;
ArrShape[i].Left := Random(Width - ArrShape[i].Width);
ArrShape[i].Top := Random(Height - ArrShape[i].Height);
end;
ArrShape[i].Brush.Color := Random(clWhite);
end;
end;
end.
__________________
Жизнь такова какова она есть и больше никакова.
Помогаю за спасибо.
|