unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Menus;
type
TForm1 =
class(TForm)
MainMenu1: TMainMenu;
Datei1: TMenuItem;
Beenden1: TMenuItem;
Neu1: TMenuItem;
Button2: TButton;
procedure Beenden1Click(Sender: TObject);
procedure Neu1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
x:integer;
implementation
uses Unit2;
{$R *.DFM}
//Menü Beenden-Button
procedure TForm1.Beenden1Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Neu1Click(Sender: TObject);
var
y,i,a: Integer;
const
NamePrefix = '
Panel';
begin
Form2.showmodal;
if (Form2.ShowModal = mrOK)
then
begin
x := Form2.ComboBox1.ItemIndex;
Case x
Of
1:
begin
a := 10;
for i := 1
to 2
do begin
TPanel.Create(Self).
Name := NamePrefix + IntToStr(i);
with TPanel(FindComponent(NamePrefix + IntToStr(i)))
do
begin
width := 120;
height := 120;
Left := 10;
Top := a;
a := a +130;
Parent := self;
end;
end;
a := 10;
for i := 1
to 2
do begin
TPanel.Create(Self).
Name := NamePrefix + IntToStr(i);
with TPanel(FindComponent(NamePrefix + IntToStr(i)))
do
begin
width := 120;
height := 120;
Left := 140;
Top := a;
a := a +130;
Parent := self;
end;
end;
end;
2:
begin
ShowMessage('
Hallo 2');
end;
3:
begin
ShowMessage('
Hallo 3');
end;
4:
begin
ShowMessage('
Hallo 4');
end;
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var a,i :integer;
const
NamePrefix = '
Panel';
begin
a := 10;
for i := 1
to 2
do begin
TPanel.Create(Self).
Name := NamePrefix + IntToStr(i);
with TPanel(FindComponent(NamePrefix + IntToStr(i)))
do
begin
width := 120;
height := 120;
Left := 10;
Top := a;
a := a +130;
Parent := self;
end;
end;
a := 10;
for i := 3
to 4
do begin
TPanel.Create(Self).
Name := NamePrefix + IntToStr(i);
with TPanel(FindComponent(NamePrefix + IntToStr(i)))
do
begin
width := 120;
height := 120;
Left := 140;
Top := a;
a := a +130;
Parent := self;
end;
end;
end;
end.