Page 1 of 2

DisableBlinkFeatures does not seem to work

Posted: Tue Apr 25, 2023 8:47 am
by lasaranza
Hi,

I noticed in my Delphi application that the Windows dark mode theme are applied to all the menu items of main menu and popup menu. This happens only when I have CEF running. I tried to fix this by setting GlobalCEFApp.DisableBlinkFeatures := 'AutoDarkMode', but this flag does not seem to work.
I am using the latest release version.

The dark mode is removed when I use SetThemeAppProperties(0), but of course all controls will look old which is not the desired outcome. Btw, this also happens to the demo projects.

Any idea how to disable the dark theme in CEF so it won't interfere the theme of other controls? Thank you in advance.
dcef-menu.png

Re: DisableBlinkFeatures does not seem to work

Posted: Tue Apr 25, 2023 11:23 am
by salvadordf
I haven't checked the dark mode settings lately but if that doesn't work I would remove all the context menu items and then send a message to the main application thread to show a custom popup menu. You can also use custom JavaScript dialogs.

Use the TChromium.OnBeforeContextMenu event and call model.clear to remove all menu items. Save the params.XCoord and params.YCoord values to show your custom popup menu.

Re: DisableBlinkFeatures does not seem to work

Posted: Tue Apr 25, 2023 12:15 pm
by lasaranza
I will try this way for the context menus. Thank you so much.
But what do you suggest for the main menu which is filled during design time?

Re: DisableBlinkFeatures does not seem to work

Posted: Tue Apr 25, 2023 1:07 pm
by lasaranza
It did not work because my menu items are actually from Delphi controls. I am using the browser in some forms of my app, but somehow it affects the theme of all menu items when Windows dark mode is enabled.

Re: DisableBlinkFeatures does not seem to work

Posted: Thu Apr 27, 2023 10:35 am
by salvadordf
This seems to be an issue for some Chrome users too.

We had a similar discussion here :
https://www.briskbard.com/forum/viewtopic.php?f=8&t=1927

A workaround is to use any Delphi style.

Re: DisableBlinkFeatures does not seem to work

Posted: Mon May 01, 2023 8:37 am
by lasaranza
Indeed, it works when using any Delphi style which puzzled me. But this is already a good workaround. Thank you so much!

Re: DisableBlinkFeatures does not seem to work

Posted: Wed May 10, 2023 8:28 am
by lasaranza
Hi Salvador,

I found the version where this dark mode issue on Delphi menus first occurred, and that is CEF4Delphi 106.0.5249.119. I compared the version before it (105.0.5195.127), and I didn't see changes in the sources that may cause this issue or maybe I am just wrong. Do you think it is CEF related issue?

Re: DisableBlinkFeatures does not seem to work

Posted: Wed May 10, 2023 1:17 pm
by salvadordf
The CEF4Delphi's code changes between 105 and 106 were totally unrelated to this issue.
This was probably a change in Chromium's code.

Re: DisableBlinkFeatures does not seem to work

Posted: Mon May 15, 2023 10:46 am
by lasaranza
Thank you for the confirmation.

Re: DisableBlinkFeatures does not seem to work

Posted: Thu Jun 29, 2023 2:25 pm
by salvadordf
Another user in the official CEF forum has requested a new feature to disable the dark mode :
https://magpcss.org/ceforum/viewtopic.php?f=6&t=19495
https://github.com/chromiumembedded/cef/issues/3534

Chromium is calling an undocumented Windows API function called "AllowDarkModeForApp" here :
https://source.chromium.org/chromium/chromium/src/+/main:content/app/content_main_runner_impl.cc;l=872?q=AllowDarkModeForApp&ss=chromium

In case someone wants to test those undocumented functions, the Double Commander project includes all the functions related to the dark mode here :
https://github.com/doublecmd/doublecmd/blob/master/src/platform/win/udarkstyle.pas