2
votes

There is some code regarding embedding a FMX form into a panel...

http://docwiki.embarcadero.com/CodeExamples/XE5/en/FMXEmbeddedForm_(Delphi)

....I want to embed multiple forms into the same panel, closing the prior one of course. I'm having an issue with the proper to close./free those forms when using the method to embed them from that docwiki.

from testing I have found that the form is not actually embedded but that the objects on the form are moved onto a new parent simulating the effects of an embedded form.

In the vcl this was pretty easy to do but in dmx it's a different ball game.

Any thoughts?

2
Love how they spell embed in that example! Anyway, did you try doing it the same way as you would in VCL, namely assigning the child form's Parent.David Heffernan
Yes David thats the first thing i tried. I had this working perfectly in the vcl. The dmx form does not embed it's self onto the other formMark Ellis

2 Answers

1
votes

The easiest method to do this is to put a transparent layout on each form as top level component.

When you need to embed a form in your panel, just create an instance of your form and change the parent of it's layout to your panel. When you don't need the embedded form, you can reparent the layout to its form and free it.

0
votes

When you embed a form you are, as you state, reparenting some of the components from the embedded form onto the containing form.

If you want to remove those components you can either:

  • reparent them to something other than the containing form (e.g. back to their original form). Do this if you have multiple forms which you want to be able to swap in and out without having to destroy and recreate all the time.
  • Free the embedded form (use DisposeOf under ARC). This will both destroy the form and it's controls and remove them from the containing form. (Note that while the containing form becomes the Parent, the original, embedded form stays as the Owner. This the controls are destroyed when the embedded form is destroyed.

You can then create and reparent another form in it's place.

Also note that you can safely embed multiple forms onto one container form but you will need to use a different object as a container for each one. You can also put multiple components or sets of components onto an embeddable form and embed them into separate locations on a container form or even onto multiple forms.

However you can only embed each control(s) into one form at a time.