I've been digging into this for the last few days, Dark Mode for Win32 programs, with a lot of mixed results
Detecting Light vs Dark Mode
I used to use GetSysColor_() to check the user's window color, and apply my light or dark GUI colors from there...
In recent Windows (Win 11 tested), this doesn't seem to work with the "Dark Mode" toggle in system settings.
For example, set "App Dark Mode" active, and check GetSysColor_(#COLOR_WINDOW) from PB... I get a typical light color value!
Seems a registry value to indicate Dark Mode is the best method.
Detecting when system colors change
Similarly, I used to WM_THEMECHANGED or WM_SYSCOLORCHANGED in window callbacks to detect when user's theme changed.
These messages don't seem to be triggered by the "Dark Mode" toggle in recent Windows!
Theming Gadgets
Look at the supported gadget types in SetGadgetColor()... If your GUI only uses these gadgets, that's good news, you can mostly apply a dark theme
With some exceptions... for example the headers in ListIconGadget or the scrollbars in various gadgets, they still appear default/light.
Some common gadgets which don't have SetGadgetColor() support are ButtonGadget, CheckboxGadget, PanelGadget...
I guess these would require complex API work to intercept drawing, or else fully custom replacements (for example I wrote a "DrawnPanelGadget" based on CanvasGadget).
Theming Windows
You can use SetWindowColor() to apply a dark color.
This also sets the background color of a Toolbar - but not the Toolbar text, so you can end up with dark-on-dark.
This does NOT change the colors of Menu or StatusBar - but I believe some of you Win API experts have workarounds for those.
DwmSetWindowAttribute() can be used to set a dark title bar on recent Windows - I confirmed this works! But with a catch: it doesn't immediately redraw the title bar. But you can solve that with a simple unfocus / re-focus API call.
Even more...
Imagine you got your entire PureBasic Win32 app dark themed, looking good, dynamically changing. Very nice.
But: MessageRequesters, file dialogs, maybe popup menus, all those other things still can't be themed, or perhaps it requires even more API hook work.
Notepad++ is one of the best examples I can find of a Win32 software which, through much hard work, has a very thorough Dark Mode.
But even then, file requesters and some other features retain their regular, light, Win32 colors! It's frustrating.
Personally, this is at a time when I'm switching from Windows to Linux, so i'm much more invested in getting Dark Mode and theming working there instead
Various references:
https://learn.microsoft.com/en-us/windo ... ows-themes
https://github.com/notepad-plus-plus/no ... /pull/9587
https://www.softwareok.com/?seite=faq-W ... d-C&faq=34
https://stackoverflow.com/questions/793 ... -statusbar