Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I write a Global proc. to create forms?

Status
Not open for further replies.

RyanEK

Programmer
Apr 30, 2001
323
AU
Hello!

I have a number of MDI forms that I want created via a global formcreate proc. Whats the best way to do this?

Currently I'm doing this:

procedure m_CreateForm(var frm:TForm;sfrm:string);
begin
Application.CreateForm(TFormClass(FindClass(sfrm)),frm);
end;

To execute I call:
m_CreateForm(TForm(frmChild),'TfrmChild');

As you can see its pretty ugly. I'm also using 'FindClass' which means i have to call 'RegisterClass' in the initialization of every MDI form. Yuck!

Does anyone have an alternative solution?

thanks
Ryan

 
why not simply

procedure m_CreateForm(var frm:TForm;sfrm:string);
var
NewForm: TForm;
begin
NewForm := TForm.Create(Application);
NewForm.Name := sfrm;
..
end;


Rod
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top