Search code examples
delphifiremonkeydelphi-10.4-sydney

Delphi FMX FormStyle StayOnTop only while app is active


Delphi 10.4 FMX desktop project

I create a form and set its FormStyle to StayOnTop. The window works as expected, staying on top of other windows in the project.

But when the app goes into the background, this form stays on top of all other apps. How do get this window to go into the background like all the other windows in the project?


Solution


  • did you try to make OnActivate and OnDeactivate on **MainForm** ? :
    procedure TForm1.FormActivate(Sender: TObject);
    begin
      if Assigned(Form2) then
        Form2.FormStyle := TFormStyle.StayOnTop;
    end;
    
    procedure TForm1.FormDeactivate(Sender: TObject);
    begin
      if Assigned(Form2) then
        Form2.FormStyle := TFormStyle.Normal;
    end;