Delphi onshow main form / modal form

前端 未结 3 1611
情歌与酒
情歌与酒 2021-02-04 16:57

I have a project which has a main form and some other forms. When the app loads it needs to carry out some tasks and show the results in a modal form on top of the main form. T

3条回答
  •  甜味超标
    2021-02-04 17:15

    Why dont you use the MainForm OnActivate event like so?

    procedure TMyMainForm.FormActivate(Sender: TObject);
    begin
      //Only execute this event once ...
      OnActivate := nil;
    
      //and then using the code David Heffernan offered ...
      with TMyOtherForm.Create(nil) do begin
        try
          ShowModal;
        finally
          Free;
        end;
    end;
    

    Setting the event to nil will ensure that this code is only run once, at startup.

提交回复
热议问题