Why is form.show called before form.create in firemonkey?

Everyone knows why Form.show is called before Form.create if the property Form.visible = true.

I tested in Delphi XE7 and Delphi 10 Seattle (Fmx form compiled for windows)

Example:


    procedure TForm1.FormCreate(Sender: TObject);
    var
      i : integer;
    begin
      //break point here is called before if form.visible = false
      i := 0;
    end;

procedure TForm1.FormShow(Sender: TObject);
var
  i : integer;
begin
  //break point here is called before if form.visible = true
  i := 0;
end;

code>
+4
source share
1 answer

If the main form is not set for visibility in the designer, the call CreateMainForm()will cause the form to be visible after completion of construction (and, therefore, after OnCreate).

procedure TApplication.CreateMainForm;
var
  I: Integer;
begin
  if FMainForm = nil then
  begin
     // here creating form...
  end;

  if FMainForm <> nil then
    FMainForm.Visible := True;  //** force visible here
end;

form Visible TCommonCustomForm.Loaded(), DFM , , OnShow, . OnCreate , , , DFM .

, , . , , .

+10

Source: https://habr.com/ru/post/1655653/


All Articles