Mike Warren 2 Posted November 12, 2023 In the past all I needed to do was add Application.ShowMainForm := False, but FMX does not have ShowMainForm. Setting the main form's Visible property to False, either at design time, or in Form.Create does nothing, and adding MyForm.Visible := False to the application anywhere before Application.Run causes an A/V. I need this to work on Windows and Mac, so a WinAPI solution is not suitable. Does anyone have a suggestion? Share this post Link to post
Nigel Thomas 35 Posted November 13, 2023 Does this help? https://stackoverflow.com/questions/14407759/delphi-xe3-mainform-hide 1 Share this post Link to post
Mike Warren 2 Posted November 13, 2023 Thanks for the reply, Nigel. Unfortunately, the form flashes up briefly at the default position and size before being hidden. Below is something I just thought of. It seems to work fine on Windows. I'm not able to test on Mac at the moment. unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs; type TForm1 = class(TForm) Timer1: TTimer; procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); private StartLeft: Integer; public { Public declarations } end; var Form1: TForm1; implementation {$R *.fmx} procedure TForm1.FormCreate(Sender: TObject); begin StartLeft := Left; Left := MaxInt; Timer1.Interval := 4000; Timer1.Enabled := True; end; procedure TForm1.Timer1Timer(Sender: TObject); begin Timer1.Enabled := False; Left := StartLeft; end; end. Share this post Link to post
Mike Warren 2 Posted November 13, 2023 (edited) 57 minutes ago, Nigel Thomas said: Does this help? https://stackoverflow.com/questions/14407759/delphi-xe3-mainform-hide Actually, that StackOverflow thread looks like it might contain the answer in the second reply. Overriding the CanShow method seems to stop the flash. function TForm1.CanShow: Boolean; begin Result := not Timer1.Enabled; end; procedure TForm1.Timer1Timer(Sender: TObject); begin Timer1.Enabled := False; Left := 500; Top := 200; Visible := True; end; Edited November 13, 2023 by Mike Warren Share this post Link to post