Page 1 of 2

Windows High Contrast Theme

Posted: Wed Mar 30, 2022 12:50 pm
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

Re: Windows High Contrast Theme

Posted: Thu Mar 31, 2022 9:17 am
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.

Re: Windows High Contrast Theme

Posted: Thu Mar 31, 2022 10:08 am
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.

Re: Windows High Contrast Theme

Posted: Fri Apr 01, 2022 6:54 am
by dilfich
Maybe I don't understand something, but these settings don't work for me. :?

Image

Re: Windows High Contrast Theme

Posted: Fri Apr 01, 2022 2:27 pm
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.

Re: Windows High Contrast Theme

Posted: Fri Apr 01, 2022 2:40 pm
by salvadordf
If you use this line to force the dark mode then remove it :

Code: Select all

GlobalCEFApp.BlinkSettings := 'forceDarkModeEnabled';

Re: Windows High Contrast Theme

Posted: Fri Apr 01, 2022 5:18 pm
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:

Re: Windows High Contrast Theme

Posted: Mon Apr 04, 2022 12:53 pm
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.

Re: Windows High Contrast Theme

Posted: Sun Dec 10, 2023 11:28 am
by Pieter E.
Hi,

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

Thank you

Re: Windows High Contrast Theme

Posted: Sun Dec 10, 2023 2:06 pm
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.