View Issue Details

IDProjectCategoryView StatusLast Update
0037717LazarusLCLpublic2020-09-07 12:21
ReporterMark Morgan Lloyd Assigned ToMattias Gaertner  
Status resolvedResolutionfixed 
Product Version2.0.10 
Summary0037717: Wishlist: alternative form of Application.CreateForm()
DescriptionPlease add an alternative form of Application.CreateForm() to the Forms unit, returning a TForm to allow the result to be assigned to a property.

Something like

function CreateForm(instanceClass: TComponentClass): TForm;

  Application.CreateForm(instanceClass, result);

Additional InformationThe intention is to allow units to contain a Lazarus-built form as a property, protecting it from unauthorised modification, in which case the .lpr file needs to look like

// Application.CreateForm(TForm1, Form1);
  Form1 := Application.CreateForm(TForm1) as TForm1;
TagsNo tags attached.
Fixed in Revision
WidgetsetGTK 2
Attached Files


Mattias Gaertner

2020-09-07 12:21

manager   ~0125422

The reason for Application.CreateForm using a var parameter is that the var Form1 is already set during creation and thus loading of the form, so any event triggered on creation can access the Form1.

Of course you can create a form on your own without this benefit:

Issue History

Date Modified Username Field Change
2020-09-07 11:25 Mark Morgan Lloyd New Issue
2020-09-07 12:21 Mattias Gaertner Assigned To => Mattias Gaertner
2020-09-07 12:21 Mattias Gaertner Status new => resolved
2020-09-07 12:21 Mattias Gaertner Resolution open => fixed
2020-09-07 12:21 Mattias Gaertner LazTarget => -
2020-09-07 12:21 Mattias Gaertner Widgetset GTK 2 => GTK 2
2020-09-07 12:21 Mattias Gaertner Note Added: 0125422