procedure MyProcedure(Num:integer);
begin
case Num of
3:
begin
if not assigned(TestForm) then
begin
TestForm:=TTestForm.Create(panel2);
TestForm.Parent:=panel2;
TestForm.Show;
end;
end;
5:
begin
if not assigned(BasicInfoForm) then
begin
BasicInfoForm:=TBasicInfoForm.Create(panel2);
BasicInfoForm.Parent:=panel2;
BasicInfoForm.Show;
end;
end;
else
begin
showmessage('Else');
end;
end;
end;
begin
case Num of
3:
begin
if not assigned(TestForm) then
begin
TestForm:=TTestForm.Create(panel2);
TestForm.Parent:=panel2;
TestForm.Show;
end;
end;
5:
begin
if not assigned(BasicInfoForm) then
begin
BasicInfoForm:=TBasicInfoForm.Create(panel2);
BasicInfoForm.Parent:=panel2;
BasicInfoForm.Show;
end;
end;
else
begin
showmessage('Else');
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MyProcedure(3);
end;
TFormClass = class of TForm;procedure ShowSpecialForm(var AForm: TForm; AClass: TFormClass);
begin
if not assgined(AForm) then
AForm := AClass.Create(panel2);
AForm.parent := panel2;
aform.show;
end;调用:3: showspecialform(tform(testform), tformclass(testform.classtype));
5: showspecialform(tform(basicinfoform), tformclass(basicinfoform.classtype));
6:
7:....
begin if not assigned(ThisForm) then
ThisForm:=TThisForm.Create(panel2);
ThisForm.Parent:=panel2;
ThisForm.Show;end;我保守估计,是不行的^_^
:1
:2
3: showspecialform(tform(testform), tformclass(testform.classtype));
只好改成
3: showspecialform(tform(testform), Ttestform);谢谢大家。