Here is my sample procdure on how to create form during runtime. Make sure the subject Tfroms are not included in auto-create. I hope it would be usefull.
/// Lets assume you have a newly created form ///
/// The subject form is Tfrm1 ///
/// Declaration ///
private
{ Private declarations }
public
{ Public declarations }
class procedure createAForm(AOwner:TComponent);
end;
{var
frmResponse: TfrmResponse;}
implementation
{$R *.dfm}
class procedure Tfrm1.createAForm(AOwner:TComponent);
var
frm:Tfrm1;
begin
frm:=Tfrm1.Create(AOwner);
with frm do begin
try
/// Optional codes before create displaying the form ///
ShowModal;
finally
Free;
end;
end;
end;
/// Now lets create the subject FORM from the main form ///
///Make sure to include the Subject Form (Tfrm1) on the uses or press ALT+F11 then click the unit///
procedure TfrmMain.button1Click(Sender: TObject);
begin
Tfrm1.createAForm(self);
end;
No comments:
Post a Comment