unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ImgList;
type
TForm1 =
class(TForm)
Timer1: TTimer;
Timer2: TTimer;
ImageList1: TImageList;
PaintBox1: TPaintBox;
//procedure WMEraseBkgnd(var Message: TMessage); message WM_ERASEBKGND;
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1 : TForm1;
image :
array[0..9]
of TImage;
pb : TPaintBox;
stein : TGraphic;
l : Integer = 0;
i : Integer = 0;
k : Integer = 0;
bmp : TBitmap;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if (k=0)
or
((k
mod 2) = 0)
then begin
image[i] := TImage.Create(Form1);
image[i].Picture.LoadFromFile('
stein.bmp');
image[i].Height := 49;
image[i].Width := 49;
image[i].Stretch := true;
image[i].Transparent := true;
imagelist1.Add(image[i].Picture.Bitmap,image[i].Picture.Bitmap);
bmp.Canvas.Draw((Random((Width-image[i].Width))),(image[i].Height),image[i].Picture.Graphic);
BitBlt(PaintBox1.Canvas.Handle, 0, 0, bmp.Width, bmp.Height, bmp.Canvas.Handle,
0, 0, SrcCopy);
//image[i].Left := Random((Width-image[i].Width));
//image[i].Parent := Form1;
//image[i].Top := -image[i].Height;
Inc(i);
end
else
begin
Inc(k);
end;
if i = 10
then timer1.Enabled := false;
end;
{procedure TForm1.WMEraseBkgnd(var Message: TMessage);
begin
// verhindert Löschen des Hintergrundes und damit das Flimmern
Message.Result := 1;
end;}
procedure TForm1.Timer2Timer(Sender: TObject);
var
j : integer;
begin
for j:= 0
to (i-1)
do
begin
BitBlt(PaintBox1.Canvas.Handle, 0, l, bmp.Width, bmp.Height, bmp.Canvas.Handle,
0, l, SrcCopy);
Inc(l);
{image[j].Top := image[j].Top + 1;
if image[j].Top >= Height then begin
image[j].top := -Image[j].Height;
image[j].Left := random(Width-Image[j].Width);
end;
}end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
bmp := TBitmap.Create;
bmp.Canvas.Brush.Color := clblack;
bmp.Width := Paintbox1.Width;
bmp.Height := Paintbox1.Height;
end;
procedure TForm1.FormDestroy(Sender: TObject);
var
l : integer;
begin
for l:=0
to 9
do image[l].Free;
end;
end.