0

In a FMX multi device project I show a form with ShowModal() and on an event of that form I call another form with ShowModal() without closing the 1st one.
But this second form stays behind the first form.

How can I set the 2nd form to be on top of the 1st form without closing the 1st form?

I've tried to set:

`FormStyle` to `StayOnTop`
Call `Form1.SendToBack`
Call Form2.BringToFront

The only way I have managed to accomplish to show the second form is by hiding the 1st form and showing it again when second form is closed.

But if possible I like to just always show the second form on top without hiding the 1st.

Is this possible?

UPDATE

Below code on how both forms are created.

NOTE: Both form2 and form3 are transparent. Maybe this has something to do with it? I've had problems with this before.

procedure TForm1.Button1Click(Sender: TObject);
var
  form2: TForm2;
begin
  form2 := TForm2.Create(nil);
  form2.ShowModal(
    procedure(ModalResult: TModalResult)
    begin
      if ModalResult = mrOk then
      begin
        //Some Code
      end;
    end);
end;

procedure TForm2.Button1Click(Sender: TObject);
var
  form3: TForm3;
begin
  form3 := TForm3.Create(nil); // I've tried to set the owner, this didn't help
  form3.Parent := Self;        // Here I've tried to set parent form2 and even form 1
  form3.ShowModal(          // This form is shown behind form2
    procedure(ModalResult: TModalResult)
    begin
      if ModalResult = mrOk then
      begin
        //Some Code
      end;
    end);
end;

So as you can see 2 forms are created showmodal. Form1 is opened with Show instead of showmodal. Form2 is created with a buttonclick event on form1 and form3 is also created with a buttonclick event, but on form2.

whosrdaddy
  • 11,720
  • 4
  • 50
  • 99
Remi
  • 1,289
  • 1
  • 18
  • 52
  • @TomBrunberg I'm sorry but how does that question got anything to do with my question? – Remi Dec 01 '16 at 08:52
  • Did you try to set the `ParentForm` property? – LU RD Dec 01 '16 at 09:18
  • @LURD how can I use ParentForm property? It's ready only – Remi Dec 01 '16 at 09:50
  • @TomBrunberg as i stated in my question it's a multi device project. So that means for Android and iOS – Remi Dec 01 '16 at 09:50
  • 1
    The value of ParentForm is set when you change the Parent property. `form2 := TForm2.Create(nil); form2.Parent := form1;` – LU RD Dec 01 '16 at 09:53
  • @LURD I have tried that, but doesn't work. Also setting owner doesn't work either. – Remi Dec 01 '16 at 10:12
  • @Remi: What you are looking for is an FMX equivalent of the VCL's `PopupParent` property, but it doesn't exist in FMX. The `Parent` property is the way to set such relationships. – Remy Lebeau Dec 01 '16 at 21:18
  • @RemyLebeau Yes, but setting the parent doesn't work. Already tried this. My 2nd form still is behind my 1st. – Remi Dec 02 '16 at 07:02
  • @Remi I don't see how the 2nd can be behind the 1st if the 1st is the Parent of the 2nd. Can you please provide a [Minimal, Complete, and Verifiable example](http://www.stackoverflow.com/help/mcve) that demonstrates the behavior? – Remy Lebeau Dec 02 '16 at 23:12
  • @RemyLebeau I've updated my question. Hope this is enough. – Remi Dec 05 '16 at 07:13
  • @Remi `form2 := ShowModal(...)` and `form3 := ShowModal(...)` are not valid statements, which means you did not copy/paste real code. Presumably you meant `form2.ShowModal(...)` and `form3.ShowModal(...)` instead. – Remy Lebeau Dec 05 '16 at 07:31
  • @RemyLebeau Yes, sorry. I've edited it. – Remi Dec 05 '16 at 08:17

0 Answers0