Mowafaq 0 Posted October 25, 2020 Hello everyone, I am having trouble showing a secondary form from the main form OnShow event for (only) the Android platform. The Show call does nothing at all except for a short delay. The main form stays active and functions correctly. The program runs nicely on Windows. This second form is StayOnTop and position=Designed with the same size as the main form. Thanks in advance for any help I can get. procedure TMainForm.FormShow(Sender: TObject); begin SetScreensLang; if MustSignIn then begin TabControl1.ActiveTab := PersonalTabItem; SignForm.Show; end else begin CheckAlerts; TabControl1.ActiveTab := AlertsTabItem; AlertsTabItemClick(nil); end; end; Share this post Link to post
Mowafaq 0 Posted October 25, 2020 Found out a work-around. Hiding the main form before the call to Show then setting MainForm.Visible := True after the secondary form closed did the trick. Never mind. Share this post Link to post
Remy Lebeau 1396 Posted October 26, 2020 Another option I can think of is to delay showing the secondary Form until after the Main Form is done fully showing itself. For instance, via TThread.ForceQueue(), eg: procedure TMainForm.FormShow(Sender: TObject); begin SetScreensLang; if MustSignIn then begin TabControl1.ActiveTab := PersonalTabItem; TThread.ForceQueue(SignForm.Show); // <-- end else begin CheckAlerts; TabControl1.ActiveTab := AlertsTabItem; AlertsTabItemClick(nil); end; end; 1 Share this post Link to post
Rollo62 536 Posted October 27, 2020 (edited) 12 hours ago, Remy Lebeau said: Another option I can think of is to delay showing the secondary Form until after the Main Form is done fully showing itself. For instance, via TThread.ForceQueue(), eg: procedure TMainForm.FormShow(Sender: TObject); begin SetScreensLang; if MustSignIn then begin TabControl1.ActiveTab := PersonalTabItem; TThread.ForceQueue( nil, procedure begin SignForm.Show; end ); // <-- Inside an anon. procedure end else begin CheckAlerts; TabControl1.ActiveTab := AlertsTabItem; AlertsTabItemClick(nil); end; end; @Remy LebeauI think you mean like above, inside an anonymous method. Edited October 27, 2020 by Rollo62 Share this post Link to post
Remy Lebeau 1396 Posted October 27, 2020 (edited) 13 hours ago, Rollo62 said: @Remy LebeauI think you mean like above, inside an anonymous method. No, I meant what I posted. An anonymous procedure is not necessary. TThread.ForceQueue() accepts both standard method closures and anonymous procedures as input, same as TThread.Synchronize() and TThread.Queue() do: type TThreadMethod = procedure of object; TThreadProcedure = reference to procedure class procedure ForceQueue(const AThread: TThread; const AMethod: TThreadMethod; ADelay: Integer = 0); overload; static; class procedure ForceQueue(const AThread: TThread; const AThreadProc: TThreadProcedure; ADelay: Integer = 0); overload; static; What I had left off by accident in my example was just the nil TThread parameter: TThread.ForceQueue(nil, SignForm.Show); Edited October 27, 2020 by Remy Lebeau 1 Share this post Link to post