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.

FMXChromium (TFMXChromium) not showing web page

Post Reply
padamjain
Posts: 23
Joined: Thu Jan 17, 2019 12:36 pm

FMXChromium (TFMXChromium) not showing web page

Post by padamjain »

Hi,

I am using TFMXChromium browser in my application. All the demo application (uSimpleFMXBrowser.pas) are working fine . but when i integrate the demo form code in my application, then web page is not loading.
any advice , if i am missing anything.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: FMXChromium (TFMXChromium) not showing web page

Post by salvadordf »

Hi,

The FMX applications require a custom application service to handle Windows messages. Check that uFMXApplicationService.pas is used in your application and call TFMXApplicationService.AddPlatformService; in the TForm.OnCreate event of your main form.

You also need to copy the CEF3 binaries and modify your DPR file to create, destroy and start GlobalCEFApp. Use the DPR code in the SimpleFMXBrowser demo.

FMX applications also need to create a TFMXWindowParent at run-time. Copy the TSimpleFMXBrowserFrm.CreateFMXWindowParent procedure from the SimpleFMXBrowser demo and call it in the TForm.OnShow event.

Your app also needs to call TFMXChromium.CreateBrowser but it will only work if GlobalCEFApp.GlobalContextInitialized is TRUE. I added a simple timer in most of the demos to call TFMXChromium.CreateBrowser again after a short period of time if it didn't succeed the first time.

In general, you should add uFMXApplicationService.pas to your project and also copy all the code from uSimpleFMXBrowser.pas and SimpleFMXBrowser.dpr files.

Read the code comments in the SimpleFMXBrowser demo. They have very important information.
padamjain
Posts: 23
Joined: Thu Jan 17, 2019 12:36 pm

Re: FMXChromium (TFMXChromium) not showing web page

Post by padamjain »

I've simply added both FMXApplicationService and uSimpleFMXBrowser to my project just like they are in the demo folder.
I can load the web browser in my other test applications but not in my main project.
I am just trying to show the TSimpleFMXBrowserFrm in my application.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: FMXChromium (TFMXChromium) not showing web page

Post by salvadordf »

In that case use the FMXToolBoxBrowser demo to show child browser forms.

Please, read the code comments in uMainForm.pas and uChildForm.pas because you need to follow some steps before closing the main form in your app.
padamjain
Posts: 23
Joined: Thu Jan 17, 2019 12:36 pm

Re: FMXChromium (TFMXChromium) not showing web page

Post by padamjain »

Thanks. in my case my application embed and disembed the forms rather then just show them individually. that is creating some issue.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: FMXChromium (TFMXChromium) not showing web page

Post by salvadordf »

Open the uFMXApplicationService.pas file and modify the TFMXApplicationService.HandleMessage procedure.

TFMXApplicationService.HandleMessage has to find the form with the browser and call these functions:
  • WM_MOVE, WM_MOVING : call NotifyMoveOrResizeStarted;
  • CEF_AFTERCREATED : call DoBrowserCreated;
  • CEF_DESTROY : call DoDestroyParent;
padamjain
Posts: 23
Joined: Thu Jan 17, 2019 12:36 pm

Re: FMXChromium (TFMXChromium) not showing web page

Post by padamjain »

Yes, I did that.
The issue i am facing is that :
When i show a form by just SimpleFMXBrowserFrm.Show , everything works well.

When i embed the form in a TPanel on my main form, then its not loading.

I've already changed the handleMessage method.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: FMXChromium (TFMXChromium) not showing web page

Post by salvadordf »

My experience with FMX is limited and I've never embedded an FMX form.

If your application is doing this to embed forms :
http://docwiki.embarcadero.com/CodeExam ... m_(Delphi)

...then I would change a few things just in case the Delphi code is recreating any handlers while reparenting all the child controls to the new form.

Embedding forms in this way only change the parent from all the child controls and this can complicate things quite a bit.
In this scenario your application only has one real form which may include several sets of components embedded from several child forms.

In this case, you would need to implement the DoBrowserCreated and DoDestroyParent in the main form and TFMXApplicationService.HandleMessage should find the main form and call them only in the main form.

I would call CreateFMXWindowParent and TFMXChromium.CreateBrowser only after embedding the child form to avoid possible problems with recreated handlers. Delete the TForm.OnShow code from the child forms.

If you only embed one browser then you can follow the "destruction sequence" described in the SimpleFMXBrowser demo but if you embed several browsers then you would need to adapt the destruction sequence from the TabbedBrowser demo.
padamjain
Posts: 23
Joined: Thu Jan 17, 2019 12:36 pm

Re: FMXChromium (TFMXChromium) not showing web page

Post by padamjain »

I found issue in my form that the handle for FMXWindowParent was not correct. so now the browser is shown in case of embedded browser.
My next step is to use multiple browsers on different forms :)
Post Reply