看看是不是这样
procedure TForm1.FormCreate(Sender: TObject);
var
ChildForm: TForm2;
i: integer;
begin
for i := 0 to 10 do
begin
ChildForm := TForm2.Create(Application);
ChildForm.Parent := self;
ChildForm.Left := 10 * (i + 1);
ChildForm.Top := 10 * (i + 1);
ChildForm.Show;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
var
i: integer;
begin
for i := ControlCount - 1 downto 0 do
begin
if Assigned(Controls) and (Controls is TForm) then
Controls.Free;
end;
end;