Page 1 of 1

FMXChromium (TFMXChromium) not showing web page

Posted: Tue Feb 19, 2019 11:50 am
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.

Re: FMXChromium (TFMXChromium) not showing web page

Posted: Tue Feb 19, 2019 12:10 pm
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.

Re: FMXChromium (TFMXChromium) not showing web page

Posted: Tue Feb 19, 2019 12:22 pm
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.

Re: FMXChromium (TFMXChromium) not showing web page

Posted: Tue Feb 19, 2019 1:00 pm
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.

Re: FMXChromium (TFMXChromium) not showing web page

Posted: Tue Feb 19, 2019 1:58 pm
by padamjain
Thanks. in my case my application embed and disembed the forms rather then just show them individually. that is creating some issue.

Re: FMXChromium (TFMXChromium) not showing web page

Posted: Tue Feb 19, 2019 2:19 pm
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;

Re: FMXChromium (TFMXChromium) not showing web page

Posted: Tue Feb 19, 2019 2:37 pm
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.

Re: FMXChromium (TFMXChromium) not showing web page

Posted: Tue Feb 19, 2019 3:20 pm
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.

Re: FMXChromium (TFMXChromium) not showing web page

Posted: Thu Feb 21, 2019 2:35 pm
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 :)