Somewhere you will need to create the form. You have to do this before you assign values to its fields or properties. frm2 := TResultsForm.Create(application); Also, as a matter of managability, I'd put the following stuff into TResultsForm.FormCreate (and free them in the Destroy event, of course). frm2.IndexObj:= TIndexerO.Create(); frm2.AnalysisObj := TAnalysisO.Create(Server1,0,0,0,0,'',''); frm2.UserObj := TUserO.Create();
Jeremy ________________________________ From: advanced_delphi@yahoogroups.com on behalf of mcmahling Sent: Mon 5/24/2010 3:27 PM To: advanced_delphi@yahoogroups.com Subject: [advanced_delphi] Dynamic Runtime Form Creation I have Delphi 2010 VCL application that has several forms that I do not want to automatically create at the application start-up. I also have custom forms that I use as a base class so that I can more easily pass data among forms. The code I use to open the forms is below; however, the only way to get it to work is to automatically create forms at application start-up. Can anyone help me change the code below or add some other procedure to allow runtime form creating? Thanks procedure TFrmExtractor.OpenResultsForm(frm2: TResultsForm; ResultsObj: TAnalysisReturnsO; Server1: IServer); var str1 : String; int1: integer; begin try frm2.ResultsObj := ResultsObj; frm2.IndexObj:= TIndexerO.Create(); frm2.IndexObj.IndexingServer := Server1; frm2.AnalysisObj := TAnalysisO.Create(Server1,0,0,0,0,'',''); frm2.UserObj := TUserO.Create(); SetWindowLong(frm2.Handle, GWL_EXSTYLE, GetWindowLong(frm2.Handle,GWL_EXSTYLE) or WS_EX_APPWINDOW); if frm2.ShowModal = mrOK then begin end else begin try Self.ResultsObj := frm2.ResultsObj; Self.IndexObj := frm2.IndexObj; except end; end; finally end; end;
<<winmail.dat>>