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.

Two browsers in the same window

Post Reply
sboydlns
Posts: 7
Joined: Fri Jan 13, 2023 7:48 pm

Two browsers in the same window

Post by sboydlns »

I am porting my application from CEF3 to DCEF4 and things are going fairly well except for one program. This program has 2 browsers in the same form. They are contained in separate pages of a page control and the user can switch between by clicking the tabs of the page control. I am going to admit right up front that this program is a hacked up kludge but it works using CEF3.

The first browser is created using a TChromium control on the main form with a TCEFWindowParent in the first page of the page control. No problem. The second browser is wholly contained in another TForm that is attached to the second page of the page control using TForm.CreateParented. This second form has a bunch of logic in it to interact with OpenStreetMaps and is used as a standalone form in other parts of the application. The second form has its own TChromium and TCEFWindowParent controls. You don't have to tell me, I know it's a dog's breakfast.

Using this setup the browser pages work intermittently. Some times the first one works, sometimes the second. It seems to depend on which events fire first. My question is how can I make two separate browser windows work reliably in a single form? Can I attach both TCEFWindowParent controls to the same TChromium? Would that fix my problem?

Thanks in advance
Steve
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Two browsers in the same window

Post by salvadordf »

Hi,

I would suggest that you move all the code and controls from that parented form into a TFrame.
Then you can use the code in the TabbedBrowser2 demo in your application.
sboydlns
Posts: 7
Joined: Fri Jan 13, 2023 7:48 pm

Re: Two browsers in the same window

Post by sboydlns »

It turned out to be something incredibly obscure that was caused by a quirk of the DCEF4 implementation. I created a child class of TChromium that overrode doLoadEnd and doLoadStart. This worked great with CEF3 but DCEF4 doesn't create the load event handler interface if OnLoadStart and OnLoadEnd are nil, causing doLoadEnd and doLoadStart to not fire. So, I changed my class so that I used OnLoadStart and OnLoadEnd handlers instead. Everything was great until an application which used my class decided that it needed OnLoadEnd. Now my OnLoadEnd no longer fired causing me much confusion.

In any case, all fixed now. Thanks for your help.

Steve
Post Reply