5

I know I'm probably missing something, but I can't understand what. I've just created a test application with 2 forms (Form1, Form2). I've added a button to Form1 with the following code in the OnClick event handler:

 Application.CreateForm(TForm2,Form2);
 Form2.Show;

When I click the button, a second form is shown as it is meant to, but if I click on Form1 I can't bring it to the front even if it has the property TopMost set to true.

What am I missing? How can i fix it? I need to show some subforms and a main form that have to be always on top.

w5m
  • 2,286
  • 3
  • 34
  • 46
Torsen
  • 151
  • 1
  • 7
  • Looks like form1 is the owner of form2. And I mean owner in the Windows sense. In the VCL, the term would be popup parent. – David Heffernan Nov 25 '12 at 21:29
  • 3
    Yep, all forms created by FMX have `ParentWnd` set in `TPlatformWin.CreateWindow`. The first form created uses `GetDesktopWindow` which seems like a terrible idea. And subsequent forms use the first form's window handle. Which means that subsequent forms are always owned by the first form created. Which sucks. No idea how to fix it because I don't use FMX. I hope I never have to. – David Heffernan Nov 25 '12 at 21:44
  • On XE2 it works as expected. If I compile with XE3 I can bring the first form on top using using WinDowse (tab Modify -> stay on top). But I don't know which API and parameters they are using to do the magic... – iPath ツ Nov 26 '12 at 08:06
  • Yes, the code appears to have changed from XE2 to XE3. In XE2, the owner is always `GetDesktopWindow`. Well, modal forms get special treatment, but that's off topic. It looks to me like this is just a design limitation in FMX. – David Heffernan Nov 26 '12 at 13:53

1 Answers1

0

I think i can help you!

First, you must create new form by chose File > New > FireMonkey Form | Delphi will save this form as unit2.pas in same project with form1

In unit1.pas, you code:

uses Unit2;

After in unit2.pas, you code 'uses Unit1'

Now, you had mutiple Windows and could do anything

You can Show Form2 by: 'Form2.Show'

Bye!Good luck...