P
publicnews
Unregistered / Unconfirmed
GUEST, unregistred user!
下面用TFormClass的方法为什么不行,如何才能使其工作正常
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.OpenForm(aFormClass:TFormClass;Obj:TForm);
begin
Obj:=aFormClass.Create(Application);
//Application.CreateForm(aFormClass,Obj);
Obj.Show;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
OpenForm(TForm2,Form2);
Form2.Caption:='test'
//不行
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
Form2:=TForm2.Create(Application);
Form2.Show;
Form2.Caption:='test'
//可以
end;
end.
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.OpenForm(aFormClass:TFormClass;Obj:TForm);
begin
Obj:=aFormClass.Create(Application);
//Application.CreateForm(aFormClass,Obj);
Obj.Show;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
OpenForm(TForm2,Form2);
Form2.Caption:='test'
//不行
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
Form2:=TForm2.Create(Application);
Form2.Show;
Form2.Caption:='test'
//可以
end;
end.