unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 =
class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
type TTestImage =
class(Timage)
protected
procedure MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
end;
var
Form1: TForm1;
Images:
array[0..4]
of TTestImage;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
for i := 0
to 4
do
begin
Images[i] := TTestImage.Create(Form1);
with Images[i]
do
begin
Name := '
Image'+IntToStr(i);
Width := 50;
Left := (i * Width) + 2;
Canvas.Brush.Color := clRed;
Canvas.FillRect(ClientRect);
Height := 50;
Top := 2;
Parent := Form1;
OnMouseDown := MouseDown;
end;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeAndNil(Images);
end;
{ TTestImage }
procedure TTestImage.MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ShowMessage((Sender
as TTestImage).
Name);
end;
end.