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.

Browser background

Post Reply
petko
Posts: 52
Joined: Sun Jul 02, 2017 9:58 am

Browser background

Post by petko »

I use TChromiumWindow and create a browser using CreateBrowser method (and then load an HTML using LoadStringW method).

However, after upgrading to the latest release (was using 3.3282.1741 previously [February 25, 2018 commit]), when I create a browser, there are two visual glitches during creation. First the browser background is gray, then part of it is black and then it is rendered with content. In the previous version the background was always white and no gray/black areas were shown.

What could be changed that causes this? I see that TChromiumWindow has a Color properly, but it can't be changed (the change won't stick).
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Browser background

Post by salvadordf »

Please, check if any of the TChromiumWindow parents uses the "doublebuffer" property.
Some other users reported similar glitches when they used that property.

Make sure you set GlobalCEFApp.BackgroundColor in the DPR file too.
petko
Posts: 52
Joined: Sun Jul 02, 2017 9:58 am

Re: Browser background

Post by petko »

I have no DoubleBuffer property set anywhere.

The GlobalCEFApp.BackgroundColor helped though: if I set it to clWhite, the gray flicker no longer happens (interestingly, if I set it to clWindow, instead of gray, I get black).

The partial black flicker however remains. Even if I set a minimal html (for example <p>text</p>), there is a partial black flicker on the bottom of the chrome window on browser creation..
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Browser background

Post by salvadordf »

petko wrote: Thu Jun 07, 2018 8:37 pm I have no DoubleBuffer property set anywhere.
The GlobalCEFApp.BackgroundColor helped though: if I set it to clWhite, the gray flicker no longer happens (interestingly, if I set it to clWindow, instead of gray, I get black).
That property has a TCefColor type. Use this code to set it to white :

Code: Select all

GlobalCEFApp.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
petko wrote: Thu Jun 07, 2018 8:37 pm The partial black flicker however remains. Even if I set a minimal html (for example <p>text</p>), there is a partial black flicker on the bottom of the chrome window on browser creation..
This could be a Delphi redrawing issue. Do you see that flicker in the SimpleBrowser demo?
petko
Posts: 52
Joined: Sun Jul 02, 2017 9:58 am

Re: Browser background

Post by petko »

Yes, probably its Delphi-drawing issue, because I create the browser in a frame. I suspect that the problem is somewhere in the frame initialization. I was just wondering what could've changed in Cef4Delphi, because it was working without this glitch in the previous versions.

SimpleBrowser does not have this issue
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Browser background

Post by salvadordf »

I did a quick check in the recent commits since February and there is one change that might result in different behavior.

I had to modify TCEFWindowParent.GetChildWindowHandle to avoid some problems creating popup browsers with CEF3. Now it checks that the component's handle is allocated before trying to use it, which would create the handle automatically.

That function is used when the component receives WM_ERASEBKGND so it could have a different behavior erasing the background before the component's handle is created.

If you create the frame in runtime, try calling TChromiumWindow.CreateHandle after you create TChromiumWindow and you set TChromiumWindow.parent.

It's also possible that Chromium has changed the way it draws the web contents.
petko
Posts: 52
Joined: Sun Jul 02, 2017 9:58 am

Re: Browser background

Post by petko »

The CreateHandle trick doesn't work, but I've found some hack that makes thing bearable for now. Thanks!
tscheidegger
Posts: 1
Joined: Wed Jul 15, 2020 12:01 pm

Re: Browser background

Post by tscheidegger »

@petko
I encounter a similar problem with a frame created in runtime and I don't get it to draw.
You wrote "I've found some hack"
Could you share your it?
Post Reply