Recent

Author Topic: tForm.Create, CreateNew, tApplication.CreateForm  (Read 15500 times)

Martin V

  • Full Member
  • ***
  • Posts: 139
tForm.Create, CreateNew, tApplication.CreateForm
« on: June 28, 2011, 11:56:58 pm »
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

  • Hero Member
  • *****
  • Posts: 5575
    • Bart en Mariska's Webstek
Re: tForm.Create, CreateNew, tApplication.CreateForm
« Reply #1 on: June 29, 2011, 12:11:51 am »
Why do you want to use TApplication.CreateForm to create a form without resources (i.e. from scratch)?


Bart

Martin V

  • Full Member
  • ***
  • Posts: 139
Re: tForm.Create, CreateNew, tApplication.CreateForm
« Reply #2 on: July 02, 2011, 12:00:12 pm »
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

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: tForm.Create, CreateNew, tApplication.CreateForm
« Reply #3 on: July 02, 2011, 03:26:16 pm »
Try
Code: [Select]
  MyForm := tMyForm.CreateNew (nil);
  MyForm.Show;
  Application.UpdateMainForm (MyForm);
AFAIK default is Visible=False.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Martin V

  • Full Member
  • ***
  • Posts: 139
Re: tForm.Create, CreateNew, tApplication.CreateForm
« Reply #4 on: July 02, 2011, 11:25:15 pm »
> 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

  • Hero Member
  • *****
  • Posts: 5575
    • Bart en Mariska's Webstek
Re: tForm.Create, CreateNew, tApplication.CreateForm
« Reply #5 on: July 03, 2011, 02:07:06 pm »
Yes,... 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

  • Hero Member
  • *****
  • Posts: 8819
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: tForm.Create, CreateNew, tApplication.CreateForm
« Reply #6 on: July 03, 2011, 04:15:13 pm »
Quote
Parsing the commandline has nothing to do with TApplication.
It has, LCL applications have standard compiler options handled like --debug-log.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11454
  • Debugger - SynEdit - and more
    • wiki
Re: tForm.Create, CreateNew, tApplication.CreateForm
« Reply #7 on: July 03, 2011, 09:26:41 pm »
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

  • Full Member
  • ***
  • Posts: 139
Re: tForm.Create, CreateNew, tApplication.CreateForm
« Reply #8 on: July 03, 2011, 11:42:00 pm »
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

  • Administrator
  • Hero Member
  • *
  • Posts: 11454
  • Debugger - SynEdit - and more
    • wiki
Re: tForm.Create, CreateNew, tApplication.CreateForm
« Reply #9 on: July 04, 2011, 12:18:29 am »
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

  • Sr. Member
  • ****
  • Posts: 251
Re: tForm.Create, CreateNew, tApplication.CreateForm
« Reply #10 on: July 04, 2011, 05:55:20 pm »
There 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.

 

TinyPortal © 2005-2018