unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Contnrs, Qbuttons;
type
TForm1 =
class(TForm)
Button1: TButton;
Label1: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
DeineObjektListe:tobjectlist;
procedure ButtonClick(Sender: TObject);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ButtonClick(Sender: TObject);
begin
if Sender
is TButton
then
begin
if TButton(Sender).Tag = 0
then
begin
TButton(Sender).Tag := 1;
TButton(Sender).Caption := '
An';
end
else
begin
TButton(Sender).Tag := 0;
TButton(Sender).Caption := '
Aus';
end;
label1.caption:=inttostr(TButton(Sender).top)+'
/'+inttostr(TButton(Sender).left);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
NewButton:
array[1..10,1..10]
of TButton;n,m:integer;
begin
For n:=1
to 10
do
For m:=1
to 10
do
begin
NewButton[n,m] := TButton.Create(Self);
NewButton[n,m].Parent := Form1;
NewButton[n,m].Caption := '
Aus';
NewButton[n,m].top:=n*NewButton[n,m].height;
NewButton[n,m].left:=m*NewButton[n,m].width;
NewButton[n,m].OnClick := ButtonClick;
DeineObjektListe.Add(NewButton[n,m]);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DeineObjektListe:=TObjectList.create;
DeineObjektListe.OwnsObjects:=true;
end;
procedure TForm1.FormDestroy(Sender: TObject);
var n:integer;
begin
// For n:=DeineObjektListe.Count-1 do DeineOjektliste.items[n].free;---> durch DeineObjektListe.OwnsObjects:=true überflüssig
DeineObjektListe.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
DeineObjektListe.Remove(DeineObjektListe.items[22]);
end;
end.