procedure TForm1.ShowForm(aFormClass: TFormClass);
var
i :Integer;
begin
for i := 0 to Self.Panel1.ComponentCount-1 do
if Self.Panel1.Components[i].InheritsFrom(TForm) then
Self.Panel1.Components[i].Free;
with aFormClass.Create(Self.Panel1) do
begin
ManualDock(Self.Panel1);
Parent :=Self.Panel1;
Show;
end;
end;
这个更懒人的做法,撒手不管型的。FForm也不用定义了。
统一用一个aForm搞定
var
aForm: TForm;
if Assigned(aForm) then aForm.Free;
aForm :=TxxxForm.Create(Application)
...
aForm.Parent :=Self.pnlContainer;
aForm.Show;