Vcl.Forms.TForm.Create

From RAD Studio API Documentation
Jump to: navigation, search

C++

/* TCustomForm.Create */ inline __fastcall virtual TForm(System::Classes::TComponent* AOwner) : TCustomForm(AOwner) { }
/* TCustomForm.CreateNew */ inline __fastcall virtual TForm(System::Classes::TComponent* AOwner, int Dummy) : TCustomForm(AOwner, Dummy) { }
/* TWinControl.CreateParented */ inline __fastcall TForm(HWND ParentWindow) : TCustomForm(ParentWindow) { }

Properties

Type Visibility Source Unit Parent
constructor public Vcl.Forms.hpp Vcl.Forms TForm

Description

Creates and initializes a TForm instance.

This is the constructor for TForm.

For Delphi, the constructor for TForm is Vcl.Forms.TCustomForm.Create. A description of the constructor for both Delphi and C++ is located at Vcl.Forms.TCustomForm.Create.

Most applications do not call TForm, but rather instantiate a descendant of TForm that is defined in the forms designer. In applications that do create TForm instances, call TForm indirectly, using the new keyword, to create a new form object at run time. Forms added to an application at design time are created automatically.

Pass a single Component as a parameter to provide the form with an Owner (usually the application) that is responsible for freeing it. This is the most commonly used constructor syntax.

Pass a Component and an integer to create the form while bypassing the streaming system that loads a form’s properties and descendants from a .DFM file. The second parameter (Dummy) serves only to distinguish this constructor from the first. This constructor is rarely used for form objects. When using this syntax, stream in an external .DFM to bind the visual components with their classes. WriteComponentResFile and ReadComponentResFile must bracket the constructor call. The following code sequence:

  1. Streams out an external .DFM file.
  2. Creates a new form disassociated from any .DFM resource file.
  3. Streams in the external .DFM file and binds it to this new form.
WriteComponentResFile("Temp.dfm", Form1);
// ...
Form2 = new TForm(Application, 1);
ReadComponentResFile("Temp.dfm", Form2);

Pass a window handle as a parameter to embed the form in a non-VCL window. This syntax is used when the form is implemented as an ActiveX control that is embedded in a non-VCL window.