tForm.Create, CreateNew, tApplication.CreateForm lazarus / 31-LCL ---------------------------------------------------------------------- Martin V · 2011-06-28 21:56 Since some months, you have to create a new form which is not designed in the resource designer via tForm.CreateNew instead of Create. If I want to create a form via tApplication.CreateForm, what is the correct way for a form without resources? I have seen an error message in the terminal window on Mac that CreateNew is needed. Is there a tApplication.CreateNewForm missing? ---------------------------------------------------------------------- Bart · 2011-06-28 22:11 Why do you want to use TApplication.CreateForm to create a form without resources (i.e. from scratch)? Bart ---------------------------------------------------------------------- Martin V · 2011-07-02 10:00 Because the form has no resources. The few components are created via Pascal source. Meanwhile, I tried (on MacOS X)   MyForm := tMyForm.CreateNew (nil);   Application.UpdateMainForm (MyForm); but the form does not appear on runtime. ---------------------------------------------------------------------- Blaazen · 2011-07-02 13:26 Try Code: [Select]  MyForm := tMyForm.CreateNew (nil);   MyForm.Show;   Application.UpdateMainForm (MyForm); AFAIK default is Visible=False. ---------------------------------------------------------------------- Martin V · 2011-07-02 21:25 > MyForm.Show Yes, thanks. Now the main form is shown. But the behaviour is different because MyForm.Show is not within Application.Run and before, there are some things not ready, for example reading commandline parameter does not work. If noone has an idea, I will report the problem in the bugtracker. I think that the authors of the createnew functionality forgot an Application.CreateFormNew. ---------------------------------------------------------------------- Bart · 2011-07-03 12:07 Quote from: Martin V on July 02, 2011, 11:25:15 pmYes,... there are some things not ready, for example reading commandline parameter does not work. I find this hard to believe. Parsing the commandline has nothing to do with TApplication. AFAIK it (ParamCount/ParamStr()) resides in the system unit. Bart ---------------------------------------------------------------------- Leledumbo · 2011-07-03 14:15 QuoteParsing the commandline has nothing to do with TApplication.It has, LCL applications have standard compiler options handled like --debug-log. ---------------------------------------------------------------------- Martin_fr · 2011-07-03 19:26 Code: [Select]TMyForm = class ...   public   Constructor Create(AOwner: TComponent); override; and then call CreateNew, instead of inherited? Then is should work in Application.CreateForm ---------------------------------------------------------------------- Martin V · 2011-07-03 21:42 thanks, Martin_fr, your trick with overwriting the constructor create with inherited createnew works in my case. Anyway, I will report the problem in the bugtracker. tApplication.CreateForm calls tForm.Create and there has to be a second procedure or a boolean variable to distinguish between Create and CreateNew. ---------------------------------------------------------------------- Martin_fr · 2011-07-03 22:18 There is somewhere a global boolean variable, to switch off the exception triggered in normal "Create" of a form. I am sure it is on the wiki (probably release notes). But since the wiki is currently down.... ---------------------------------------------------------------------- DirkS · 2011-07-04 15:55 Quote from: Martin_fr on July 04, 2011, 12:18:29 amThere is somewhere a global boolean variable, to switch off the exception triggered in normal "Create" of a form. You're probably thinking of 'RequireDerivedFormResource'. New apps get a 'RequireDerivedFormResource := true' as the first line of code in the .lpr Deleting this line should be enough to switch off the exception Gr. Dirk.