firemonkey-学习2

Form的name属性在运行时可能会改变。比如说TForm1创建了3个,则实际name属性为Form1,Form1_1,Form1_2. 实际也可能是其它名字。猜想名字可能是全局唯一的。

可以选择新的模态窗口显示方式:这种方式显示的实际不是模态的。只是匿名过程的一个使用。

TCommonCustomForm = class

    function ShowModal: TModalResult; overload;
    procedure ShowModal(const ResultProc: TProc<TModalResult>); overload;

end.

procedure MyCurrentForm.MyButtonClick(Sender: TObject);
var
  dlg: TMyModalForm;
begin
  // Create an instance of a form.
  dlg := TMyModalForm.Create(nil);
 
  // Configure the form. For example, give it a display name.
  dlg.Caption := 'My Modal Dialog Box';
 
  // Show your dialog box and provide an anonymous method that handles the closing of your dialog box.
  dlg.ShowModal(
    procedure(ModalResult: TModalResult)
    begin
      // Do something.
    end
  );
end;

不过窗口并不会自动销毁。如果需要自动销毁。可以如下这样做:
procedure TMyModalForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := TCloseAction.caFree;
end;
原文地址:https://www.cnblogs.com/khzide/p/4433252.html