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.

Windows High Contrast Theme

Post Reply
thefunkyjoint
Posts: 460
Joined: Thu Aug 10, 2017 12:40 pm

Windows High Contrast Theme

Post by thefunkyjoint »

When you set High Contrast Theme in Windows, by default looks like CEF will also put dark theme on all web pages you visit, all of them shows with black background, with no additional setting on GlobalCefApp.

Is there a way to change this behaviour ? I want CEF to show pages like default, even when in High Contrast Theme in Windows.

Thanks
dilfich
Posts: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Windows High Contrast Theme

Post by dilfich »

do you manage to include a light theme on the official chrome with a contrasting one on Windows?
If so, how?
switching the "chrome://flags/#enable-force-dark" add-in doesn't help.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Windows High Contrast Theme

Post by salvadordf »

thefunkyjoint wrote: Wed Mar 30, 2022 12:50 pm When you set High Contrast Theme in Windows, by default looks like CEF will also put dark theme on all web pages you visit, all of them shows with black background, with no additional setting on GlobalCefApp.
Is there a way to change this behaviour ? I want CEF to show pages like default, even when in High Contrast Theme in Windows.
Thanks
There seems to be a lot of people asking for the same thing in the Chrome forums:
https://support.google.com/chrome/thread/32479550/cannot-disable-dark-mode?hl=en
https://support.google.com/chrome/thread/34740241/chrome-stuck-in-dark-mode?hl=en
https://support.google.com/chrome/thread/4877043/why-can-t-i-disable-dark-mode-on-chrome-without-disabling-it-for-windows-too?hl=en

Some people fix this by disabling the "Auto dark mode" flag which we can do with this code line :

Code: Select all

GlobalCEFApp.DisableBlinkFeatures := 'AutoDarkMode';
For some other sites like google.com we can turn the dark mode using their settings button :
https://windowsreport.com/dark-mode-chrome-turn-off/

Even with all these fixes some websites like youtube keep the dark mode. Perhaps you need to log in and disable it in their settings too.
dilfich
Posts: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Windows High Contrast Theme

Post by dilfich »

Maybe I don't understand something, but these settings don't work for me. :?

Image
thefunkyjoint
Posts: 460
Joined: Thu Aug 10, 2017 12:40 pm

Re: Windows High Contrast Theme

Post by thefunkyjoint »

salvadordf wrote: Thu Mar 31, 2022 10:08 am
thefunkyjoint wrote: Wed Mar 30, 2022 12:50 pm Some people fix this by disabling the "Auto dark mode" flag which we can do with this code line :

Code: Select all

GlobalCEFApp.DisableBlinkFeatures := 'AutoDarkMode';
For some other sites like google.com we can turn the dark mode using their settings button :
https://windowsreport.com/dark-mode-chrome-turn-off/

Even with all these fixes some websites like youtube keep the dark mode. Perhaps you need to log in and disable it in their settings too.
This command won't work for me :

GlobalCEFApp.DisableBlinkFeatures := 'AutoDarkMode';

Even with this, CEF4Delphi will show a black background when using Windows High Contrast Theme. You can test this in web version of Whatsapp. The problem is, with this dark mode enabled, the QR Code used to connect won't work so the only workaround is to disable Windows High Contrast Theme.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Windows High Contrast Theme

Post by salvadordf »

If you use this line to force the dark mode then remove it :

Code: Select all

GlobalCEFApp.BlinkSettings := 'forceDarkModeEnabled';
dilfich
Posts: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Windows High Contrast Theme

Post by dilfich »

Apparently there is only one way out, it's in the Windows theme settings to change the black background to white))
Which of course will affect all applications. :shock:
thefunkyjoint
Posts: 460
Joined: Thu Aug 10, 2017 12:40 pm

Re: Windows High Contrast Theme

Post by thefunkyjoint »

dilfich wrote: Fri Apr 01, 2022 5:18 pm Apparently there is only one way out, it's in the Windows theme settings to change the black background to white))
Which of course will affect all applications. :shock:
Looks like so. Let's wait for next versions.
Pieter E.
Posts: 12
Joined: Thu Oct 19, 2017 2:47 pm

Re: Windows High Contrast Theme

Post by Pieter E. »

Hi,

In the meantime, is there a solution to forcefully disable dark mode?

Thank you
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Windows High Contrast Theme

Post by salvadordf »

Hi,

Add this before the GlobalCEFApp.StartMainProcess call :

Code: Select all

GlobalCEFApp.DisableFeatures := 'WebContentsForceDark';
GlobalCEFApp.UIColorMode := uicmForceLight;
GlobalCEFApp.UIColorMode works reliably but I had inconsistent results with WebContentsForceDark.
Perhaps you'll need to clear the cache or run the browser in "Chrome runtime" mode.
Post Reply