|A 3D FireMonkey form embedded in a VCL application,|
This post is to note a bugfix that handles the case where instances of TFireMonkeyContainer are freed in a different order to the order in which they were created. This is most likely to occur if you create instances dynamically at runtime, such as in a tabbed multidocument application (like a web browser): creating one on a new tab, but freeing them in different order, such as if a user closes a different tab.
If running in debug, you would get an assert in this situation. If running in release, you would notice focus issues, where the host form may not have drawn its title bar as though it was the active form when the FMX form inside it was focused. If you only ever had one embedded FMX form per VCL form or if you never created an instance at runtime, ie only used it by placing a TFireMonkeyContainer on a form at designtime, you wouldn’t run into this bug, although this update does clean up the code and you should use this latest version anyway.
The bug was due to the control needing to subclass the VCL form on which it sits. In some slightly silly code the implications of which I overlooked, this was done once per TFireMonkeyContainer instance, but should have been done only once for a given VCL form no matter how many embedded FMX forms were on that host VCL form, and removed only when the last TFireMonkeyContainer instance was freed.
If you haven’t used TFireMonkeyContainer before, and you want to make use of FMX in your VCL app, try it out! You can find the project on Google Code, and check out or update the source from SVN. Read more posts about it on the Code & Components page.