Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

More than one browser in an FMX application

Post Reply
Philip Rayment
Posts: 9
Joined: Sun May 13, 2018 5:51 am

More than one browser in an FMX application

Post 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?
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: More than one browser in an FMX application

Post 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.
Philip Rayment
Posts: 9
Joined: Sun May 13, 2018 5:51 am

Re: More than one browser in an FMX application

Post by Philip Rayment »

Thanks Salvador, that's just the sort of information I wanted. I'll see how I go with that.
Post Reply