0

I am trying to achieve an interface similar to old versions of Access, which embeds forms inside forms inside forms.

Screenshot of old Access with forms inside forms

I have a form (Form1) and TPanel (Panel1) inside it. I created two other forms and said that their Parent=Panel1;

enter image description here

The problem is that I cannot activate Form2 (put her in front of Form3) unless I click its title bar. Clicking on the form itself has no effect, no even when dragging the form it will still be behind Form3, and I need when I click the form or drag it to automatically becomes "active", meaning in front of Form3.

How to do this? Both Delphi & C++ Builder solutions are acceptable.

David
  • 13,360
  • 7
  • 66
  • 130
Tracer
  • 2,544
  • 2
  • 23
  • 58
  • 3
    Why are you using forms parented to a panel? You seem to be reinventing the MDI interface - try using MDI child forms, and they will behave as you need. You can also look into frames, which are another container-like object and are designed for being embedded on other forms. – David Jul 29 '13 at 09:07
  • The problem is I need MDI form as a non-moveable part of normal form, and then inside MDI form I could have MDI children. – Tracer Jul 29 '13 at 09:11
  • I don't understand that comment. Could you elaborate. – David Heffernan Jul 29 '13 at 11:17
  • 3
    I'm not sure why you got 2 downvotes - there's no explanation. Drive-by downvoters are Not Good. While your question is odd, it's clear and well-asked and seems a perfectly ok question to me. I gave you a +1 to try to balance it out. – David Jul 29 '13 at 12:23
  • Thanks David M. @DavidHeffernan I need the same thing like MS Access has. A MDI form as part of the main form, and inside MDI form to be able to have MDI children forms. – Tracer Jul 29 '13 at 15:02
  • @Tracer, that kind of info - explaining what you are trying to achieve, not asking how to do the approach to it you've thought of - is very worth putting in the question. I'd edit it if I could only it's been put on hold. (Honestly, SO administration sometimes...) It leads to better understanding of your problem and better answers to your question. – David Jul 30 '13 at 08:24
  • 2
    So much harassment just to ask a question... Found my answer elsewhere in the meantime so you can close this. – Tracer Jul 30 '13 at 08:51
  • By the way, the answer is that Delphi & C++ Builder cannot do what I need. VCL is limited in a way that can only use main form as MDI form. So, I cannot create a new MDI form in the project since MDI children will say that MDI form (main form) is not active. – Tracer Jul 30 '13 at 09:11
  • You can probably do what you need by handling some messages for the forms you create, eg WM_ACTIVATE and WM_MOUSEACTIVATE, and then bring that form to the front. The VCL can certainly do it, you'll just need to hook into some of the lower level stuff yourself. – David Jul 30 '13 at 09:55

1 Answers1

3

While I agree with the rest about using MDI instead, in putting these forms in the panel you make them supplicant controls (and not forms). So you would need to listen to the Click event for each of those forms and then call BringToFront when you receive it.

procedure TForm3.FormClick(Sender: TObject);
  begin
    BringToFront;
  end;

I don't know how the event will work if you click on one of the controls of the form (whether the control event will fire instead) in such an environment, but doing this will produce the effect you're looking for.

Glenn1234
  • 2,542
  • 1
  • 16
  • 21