W
www.ynxbs.com
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TMainFrm.N1Click(Sender: TObject);
var Frm:TForm;
begin
Frm := tFrmModifyPwd.Create(nil);
Frm.ShowModal;
Frm.Free;
Frm := nil;
end;
上面是我天天在写的代码,我又把它修改成:
TFormClass=class of TForm;
procedure TDM.CreateForm(aTClass: TFormClass);
var Instance:TFormClass;
begin
Instance:= TFormClass(aTClass.Create(nil));
TForm(Instance).ShowModal;
TForm(Instance).Free;
TForm(Instance):=nil;
end;
委托数据模块顺带提供方法(挑水带洗菜),现在,就可以
procedure TMainFrm.N1Click(Sender: TObject);
begin
DM.CreateForm(tFrmModifyPwd);
end;
真清爽啊,清爽;但问题也来了,不是全部类都调用父类的Create方法,例如下面:
TStorageInfoFrm_Bom = class(TForm)
Panel2: TPanel;
btnSave: TBitBtn;
BitBtn2: TBitBtn;
Panel1: TPanel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
Label5: TLabel;
m: TADODataSet;
Edit3: TEdit;
Edit4: TEdit;
procedure Button4Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
MyData: TMyData;
GradeGroupID: integer;
function CheckData: boolean;
public
{ Public declarations }
constructor Create(AOwner: TComponent; lMyData: TMyData); overload;
//重载Form的Create构造函数。
end;
现在我该如何改造procedure TDM.CreateForm(aTClass: TFormClass)方法?建造时,要调用重载Form的Create方法,因为还要传另外参数!
达到目的:
DM.CreateForm(TStorageInfoFrm_Bom ,aMyData);
帮帮我!
var Frm:TForm;
begin
Frm := tFrmModifyPwd.Create(nil);
Frm.ShowModal;
Frm.Free;
Frm := nil;
end;
上面是我天天在写的代码,我又把它修改成:
TFormClass=class of TForm;
procedure TDM.CreateForm(aTClass: TFormClass);
var Instance:TFormClass;
begin
Instance:= TFormClass(aTClass.Create(nil));
TForm(Instance).ShowModal;
TForm(Instance).Free;
TForm(Instance):=nil;
end;
委托数据模块顺带提供方法(挑水带洗菜),现在,就可以
procedure TMainFrm.N1Click(Sender: TObject);
begin
DM.CreateForm(tFrmModifyPwd);
end;
真清爽啊,清爽;但问题也来了,不是全部类都调用父类的Create方法,例如下面:
TStorageInfoFrm_Bom = class(TForm)
Panel2: TPanel;
btnSave: TBitBtn;
BitBtn2: TBitBtn;
Panel1: TPanel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
Label5: TLabel;
m: TADODataSet;
Edit3: TEdit;
Edit4: TEdit;
procedure Button4Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
MyData: TMyData;
GradeGroupID: integer;
function CheckData: boolean;
public
{ Public declarations }
constructor Create(AOwner: TComponent; lMyData: TMyData); overload;
//重载Form的Create构造函数。
end;
现在我该如何改造procedure TDM.CreateForm(aTClass: TFormClass)方法?建造时,要调用重载Form的Create方法,因为还要传另外参数!
达到目的:
DM.CreateForm(TStorageInfoFrm_Bom ,aMyData);
帮帮我!