win32 dark mode progress

286 views
Skip to first unread message

Vojtěch Bubník

unread,
Apr 7, 2021, 3:54:55 AMApr 7
to wx-u...@googlegroups.com
Hello.

It is known that Microsoft did not publish their Win32 dark mode API, most likely namely because it is far from complete. There is no information from Microsoft about the time schedule of the Win32 dark mode API or whether they will publish Win32 dark mode API at all. I am getting a feeling that Microsoft is ditching Win32 API in favor of the UWP API and the dark mode will never come to Win32 API.

So Microsoft implemented the dark mode for those Win32 controls that are used by their products. Somebody made an effort some two years ago to reverse engineer that API, however that effort stopped about a year and half ago.


Luckily, there is an effort on the famous Notepad++ editor.


Notepad++ is a pure Win32 application, thus the Dark Mode effort is not clouded by any multi-platform layers. The Notepad++ project is active and widely used (I am using it every day myself), so there is quite a chance that they will polish the Dark Mode at least for their usage.

We at PrusaSlicer are asked quite often for Dark Mode support on Windows. We were waiting for Microsoft to help, but that will likely not happen. In the meanwhile, our customers and non-customers (users of 3rd party Chinese 3D printers) blame us for being lazy not implementing the dark mode. Thus we may invest quite a lot of time to port the dark mode from Notepad++ to PrusaSlicer. However it looks like it will be much easier to integrate it into wxWidgets.

That's the heads up on our Dark Mode troubles and effort.  We hope other wxWidgets users will chime in on Win32 Dark Mode, so we can share our journey.

Vojtech

Tim Roberts

unread,
Apr 7, 2021, 3:46:24 PMApr 7
to wx-users
Call me a heathen, I guess, but I cannot imagine why any person would care one whit about this.  Apple hyped their "dark mode", and apparently that made it cool, but holy cripes, it's just a color scheme.  Don't people have real work to do?

Julian Smart

unread,
Apr 7, 2021, 4:03:32 PMApr 7
to wx-u...@googlegroups.com
I just do a simple test for a dark background colour and light foreground colour, and adapt/simplify drawing accordingly. I think that caters for at least 90% of what dark mode needs on all platforms, though maybe there's some nuance I'm not aware of.

Regards, 

Julian

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to wx-users+u...@googlegroups.com
or visit http://groups.google.com/group/wx-users
---
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/df9169ff-c7d9-4c91-a905-54cab5d7b369n%40googlegroups.com.

QuentinC

unread,
Apr 8, 2021, 1:29:45 AMApr 8
to wx-u...@googlegroups.com
Hello,

Regarding dark mode, it also have been requested to me by a user.

According to this stack overflow question:
https://stackoverflow.com/questions/51334674/how-to-detect-windows-10-light-dark-mode-in-win32-application/51336913

I came up with this code:
bool checkDarkMode () {
#ifdef __WIN32
wxRegKey rk(wxRegKey::HKCU,
"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize");
if (rk.Exists() && rk.HasValue("AppsUseLightTheme")) {
long value = -1;
rk.QueryValue("AppsUseLightTheme", &value);
return value<=0;
}
#endif
return wxSystemSettings::GetAppearance().IsDark();
}


However, this code only does detection. You need to change colors
yourself, and wx is of no help because request system colors keeps
returning normal colors.
This explains why wxSystemSettings::GetAppearance().IsDark() in fact
never work. The window background color is always found to be white.

IN my case, I made it very very simple: if dark mode is detected, I
invert the system colors returned by the regular wxSystemSettings calls,
i.e. 255-red, 255-green, 255-blue. 3D effects are now completely wrong
and have still to be fixed, but globally it works.


BY the way, regarding colors, it would be good if HSL were implemented.
For example:
HSL(240°, 100%, 50%) is blue (= RGB(0, 0, 255)). It would be cool to
have a method like this:
wxColour::FromHSL(240.0f, 1.0f, 0.5f)
When you are partially sighted like me, it's easier to think about
colors in this way...

Have a nice day.

Vojtěch Bubník

unread,
Apr 8, 2021, 2:19:06 AMApr 8
to wx-u...@googlegroups.com
> Call me a heathen, I guess, but I cannot imagine why any person would care one whit about this.  Apple hyped their "dark mode", and apparently that made it cool, but holy cripes, it's just a color scheme.  Don't people have real work to do?

The customer is always right.

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+u...@googlegroups.com
or visit http://groups.google.com/group/wx-users
---
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-users+u...@googlegroups.com.

Vojtěch Bubník

unread,
Apr 8, 2021, 2:23:11 AMApr 8
to wx-u...@googlegroups.com
> I just do a simple test for a dark background colour and light foreground colour, and adapt/simplify drawing accordingly. I think that caters for at least 90% of what dark mode needs on all platforms, though maybe there's some nuance I'm not aware of.

I am afraid that would not do. If it was so simple, Microsoft would do that for us.


I personally find the development on Notepad++ promising, we are already looking into what they did and how we can reuse it.

Vadim Zeitlin

unread,
Apr 8, 2021, 3:59:11 AMApr 8
to wx-u...@googlegroups.com
On Thu, 8 Apr 2021 07:29:25 +0200 QuentinC wrote:

Q> According to this stack overflow question:
Q> https://stackoverflow.com/questions/51334674/how-to-detect-windows-10-light-dark-mode-in-win32-application/51336913
Q>
Q> I came up with this code:
Q> bool checkDarkMode () {
Q> #ifdef __WIN32
Q> wxRegKey rk(wxRegKey::HKCU,
Q> "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize");
Q> if (rk.Exists() && rk.HasValue("AppsUseLightTheme")) {
Q> long value = -1;
Q> rk.QueryValue("AppsUseLightTheme", &value);
Q> return value<=0;
Q> }
Q> #endif
Q> return wxSystemSettings::GetAppearance().IsDark();
Q> }

Please consider making a PR with your changes to wx.

Q> IN my case, I made it very very simple: if dark mode is detected, I
Q> invert the system colors returned by the regular wxSystemSettings calls,
Q> i.e. 255-red, 255-green, 255-blue. 3D effects are now completely wrong
Q> and have still to be fixed, but globally it works.

I'm afraid that such simplistic approach is not going to look very good,
but perhaps we could do something better in the future. Having IsDark()
working would be a good first step anyhow.

Q> BY the way, regarding colors, it would be good if HSL were implemented.

Have you seen wxImage::RGBtoHSV() and HSVtoRGB()?

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Vadim Zeitlin

unread,
Apr 8, 2021, 4:02:59 AMApr 8
to wx-u...@googlegroups.com
On Wed, 7 Apr 2021 09:54:42 +0200 Vojtěch Bubník wrote:

VB> Luckily, there is an effort on the famous Notepad++ editor.
VB>
VB> Dark Mode begins! by adzm · Pull Request #9587 ·
VB> notepad-plus-plus/notepad-plus-plus (github.com)
VB> <https://github.com/notepad-plus-plus/notepad-plus-plus/pull/9587>

Thanks for the pointer, but please note that the code in this PR is, by
default, covered by the licence of the main application, i.e. GPL, making
it unsuitable for inclusion into wxWidgets. Perhaps we could ask the PR
author to also licence these changes under wx licence...

QuentinC

unread,
Apr 8, 2021, 7:32:15 AMApr 8
to wx-u...@googlegroups.com
Hello,

VZ> Please consider making a PR with your changes to wx.

Why not. I'll try to do it.

VZ> I'm afraid that such simplistic approach is not going to look very
good, but perhaps we could do something better in the future. Having
IsDark() working would be a good first step anyhow.

Of course not, it indeed doesn't look very good. For the moment it was
just to check if it works
There is more than just changing background and foreground colors,
whatever they are.

VZ> Have you seen wxImage::RGBtoHSV() and HSVtoRGB()?

Ah no, I wasn't looking at the right place. I expected something in
class wxColour.
Thank you !

Vojtěch Bubník

unread,
Apr 8, 2021, 7:46:45 AMApr 8
to wx-u...@googlegroups.com
We have an interesting discussion here:


Frankly I am not sure what Mike Ratcliffe is trying to suggest, maybe somebody knows?

Vadim Zeitlin

unread,
Apr 8, 2021, 7:54:13 AMApr 8
to wx-u...@googlegroups.com
On Thu, 8 Apr 2021 13:46:31 +0200 Vojtěch Bubník wrote:

VB> We have an interesting discussion here:
VB>
VB> Feature request: Dark mode on Windows (10) · Issue #4493 ·
VB> prusa3d/PrusaSlicer (github.com)
VB> <https://github.com/prusa3d/PrusaSlicer/issues/4493#issuecomment-815300115>
VB>
VB> Frankly I am not sure what Mike Ratcliffe is trying to suggest, maybe
VB> somebody knows?

Yes, but you'd need to write a whole new wx port (wxUWP?) to be able to do
this. I.e. it's indeed good that it's now possible to use UWP controls in
desktop applications, but it doesn't mean that it's _easily_ possible to do
it. FWIW I'd definitely support any efforts to do such a thing, but I have
no plans of doing it myself (at least not without a massive amount of
funding for wx work falling into my lap because I just will never have
enough "free" time to do this instead and would have to stop working on my
other projects in order to do it).

Amn Ojee Uw

unread,
Apr 8, 2021, 7:58:53 AMApr 8
to wx-u...@googlegroups.com
Many times, i have hearn people stating their dislike of the dark-mode on Windoes, but never a programmer or power user. I find it more relaxing on my eyes, particularly. Having the ability to use dark-mode is very important for some users.

Regards 
Amn Ojee

PB

unread,
Apr 8, 2021, 11:17:51 AMApr 8
to wx-users
 My two (four?) cents:
  1. Users do want dark mode. They do not care nor understand (nor should they) that there is a difference between Win32 and other APIs (UWP, Electron, Qt...).
  2. Microsoft refuse to enable dark mode for Win32, having done only the absolutely necessary minimum to make File Explorer work.
  3. All Win32 dark mode uses I have seen are hacks, relying among else on undocumented hard-coded DLL exports, which change with Windows' versions, making them see rather brittle. Why this may be acceptable for an application, is this acceptable for a library such as wxWidgets?
  4. Is full dark mode Win32 even possible, in other words: Is it possible to use with all the common controls as well as common dialogs (see #2)?
Sorry for being Negative Nancy, I understand that the points above are of little help but I still think them true.

Regards,
PB

David Connet

unread,
Apr 8, 2021, 11:46:23 AMApr 8
to wx-u...@googlegroups.com
On 4/8/2021 8:17 AM, PB wrote:
> Is full dark mode Win32 even possible, in other words: Is it possible
> to use with all the common controls as well as common dialogs (see #2)

I vaguely remember trying to properly customize a list control (in
report mode, at a previous job). Gave up after a while since it wasn't
technically sanctioned work. If I remember, it was getting the non-list
area background to properly draw.

Dave

Vojtěch Bubník

unread,
Apr 16, 2021, 6:56:19 AMApr 16
to wx-u...@googlegroups.com
FYI, this is the results we are getting after just skinning Win32 controls using wxWidgets API:


This is a single woman-week effort. We had to replace notebook tabs with some other control (Oleksandra did that), as she was not able to skin it. Some controls are likely not skinnable (scroll bars?). It is an ugly mess. I understand that somebody with a medical condition may find our effort pleasing. We are really curious for the PrusaSlicer community response.


--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+u...@googlegroups.com
or visit http://groups.google.com/group/wx-users
---
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-users+u...@googlegroups.com.

Vojtěch Bubník

unread,
Apr 19, 2021, 3:57:05 AMApr 19
to wx-u...@googlegroups.com
For those of us refusing the dark mode as just a fancy skin, it may be interesting to follow the discussion at
It really seems many people prefer the dark theme because their eyes or head hurts when looking into a light source and they are not too picky about the particular visual appearance as long as it is dark and readable. I heard for example that migraines triggered by looking into a bright light may be a long term effect of tick borne encephalitis.

It may be interesting to you as well to follow our steps and interactions with our customers in regard to dark mode skinning. I am not sure whether anything from that could be added easily to wxWidgets.

What may be added to wxWidgets maybe through conditional compilation are some of the unofficial Microsoft APIs they implemented to support dark mode in their Windows Explorer, namely the dark menus and the dark scroll bars, which are impossible to skin otherwise. Our Oleksandra will look into that, however support from the wxWidgets authors would be welcome.

I am also drawing a conclusion, that Microsoft will never add dark mode to Win32 API. They are not motivated to support that legacy API, they will likely invest more effort into rewriting their Windows 10 system applications to their new graphics API compatible with the tablet mode. Microsoft may have other technical reasons to phase out Win32, for example CPU load thus battery consumption.

Václav Slavík

unread,
Apr 19, 2021, 12:50:25 PMApr 19
to wx-u...@googlegroups.com
Hi,


VB> Dark Mode begins! by adzm · Pull Request #9587 ·
VB> notepad-plus-plus/notepad-plus-plus (github.com)
VB> <https://github.com/notepad-plus-plus/notepad-plus-plus/pull/9587>

Thanks for the pointer, but please note that the code in this PR is, by
default, covered by the licence of the main application, i.e. GPL, making
it unsuitable for inclusion into wxWidgets. Perhaps we could ask the PR
author to also licence these changes under wx licence...

I’m explicitly not arguing for its inclusion in wx (feels a bit too experimental for my taste still), but note that the PR is based on interesting MIT-licensed upstream here:



Regards,
Václav

Reply all
Reply to author
Forward
0 new messages