Page 1 of 1

More than one browser in an FMX application

Posted: Wed May 16, 2018 3:10 pm
by Philip Rayment
I've created a component for FireMonkey that seems to work, that avoids having to replicate most of the code in the SimpleFMXBrowser sample. One concern I had was whether the browser had to be on the main form or not, but it seems not, as I've successfully used my component to have the browser on another form.

I know this is a very general question, but are there any issues around having more than one browser form in a FireMonkey application? Does the message handler(TFMXApplicationService.HandleMessage) in uFMXApplicationService need to be common to both, for example?

Re: More than one browser in an FMX application

Posted: Wed May 16, 2018 4:16 pm
by salvadordf
First of all, I don't have an extensive experience with Firemonkey components.

Having said that, I would do this :
  • You should call TFMXApplicationService.AddPlatformService only once in your application before creating any of your browsers.
  • TFMXApplicationService.HandleMessage will handle the messages for ALL the browsers.
  • As a consequence of that, you should send CEF_AFTERCREATED and CEF_DESTROY with a parameter to find the right form containing the right TFMXChromium. For example, you can use a custom form tag as a parameter and then modify TFMXApplicationService.HandleMessage to search the form with that tag to call DoBrowserCreated or DoDestroyParent.
  • Remember to follow the destruction sequence for all your browsers before closing your app. It's explained in the code comments.

Re: More than one browser in an FMX application

Posted: Thu May 17, 2018 9:05 am
by Philip Rayment
Thanks Salvador, that's just the sort of information I wanted. I'll see how I go with that.