1

Delphi 10.3.3

In a mobile FMX project, I want to create a form before the main form.

This form contains app tethering components that talk to Codesite. It must be created first so that the main form's FormCreate() can use it.

However, making this form first causes it to become the main form.

How do I create a form before all other forms but not have it become the main form?

Mike Torrettinni
  • 1,816
  • 2
  • 17
  • 47
Mike at Bookup
  • 1,211
  • 14
  • 32

1 Answers1

3

Use a TDataModule to host those tethering components, instead of a form. In your project file (.dpr) move the creation of the data module before the main form. Its setup code will run before the main form and the components will be available at the time of the main forms OnCreate.

TDataModule is frame work neutral and has a property called ClassGroup, that defines the framework. It controls which components are selectable in the tool palette.

Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54
  • I added the TDataModule. I cannot find where it is created but it's after the main form's FormCreate() is called. – Mike at Bookup Feb 11 '20 at 00:29
  • @Mike It is added to your project file (.dpr) which you can see if you select `Project - View source` from the menu. Then just do what I already said in my answer: *In your project file (.dpr) move the creation of the data module before the main form.* E.g. a line like `Application.CreateForm(TDataModule26, DataModule26);` moved before the first actual form is created: `Application.CreateForm(TForm25, Form25);` – Tom Brunberg Feb 11 '20 at 07:24
  • That was the weird thing. It did not appear there after adding it to the project. I worked around it by removing it from the project and adding lines to its initialization and finalization blocks to get it created and freed. However, I tried one more time to add it back to the project and sure enough this time it added the Application.CreateForm(TCodeSite, Codesite); at the end. Thanks again. – Mike at Bookup Feb 11 '20 at 17:22