Home » Blog
date 17.Feb.2024

■ Dark mode listview control misery

It is a chilling realization that after 25 years of win32 desktop programming, there's nobody you can reach out for help with hard programming problems. If you don't know the answer, most probably nobody else does, and you must figure it out without relying on any outside (natural or artificial) intelligence. The other day I asked ChatGPT for "sample C++ code that makes a message box dark", and it came up with this:

::MessageBox("This is a dark messagebox", "sample", MB_OK);

(I am not making this up). So much for AI replacing programmers.

The last couple of years I've spent an extraordinary amount of time and effort trying to make xplorer² UI controls look good in dark mode. Not that it is inherently difficult to paint something black — it's not like squaring the circle. There is just an informational void on how to do things properly without reinventing the wheel. Microsoft are busy spinning a new "universal" UI model every other month (that nobody uses) and have abandoned win32 programmers stumbling in the darkness without documentation on new features.

Take the listview control, that does all the heavy lifting in xplorer² — showing folder contents. It responds quite well to standard API like SetTextColor and SetBkColor so you can quickly get it looking 90% decently dark. But then you realize that its header control isn't as amenable; little details like scrollbars, group headers and selection colors need fixing. If you are a programmer you may have heard of a special dark theme called DarkMode_Explorer that gets you a bit closer to dark Eden, perhaps 95% there (offers dark scrollbars). But its highlighting colors give very poor contrast on windows 11.

Where are all these special themes documented? Nowhere. Last week I had a glimer of hope when I stumbled on msstyle Editor a tool that lists (and apparently modifies) aero themes like aero.msstyles inside %WINDIR%. All the dark themes you read about in stack overflow are there, including obscurities like DarkMode_CFD::Combobox (very useful btw). When I saw how many themes with darkish names exist, I was hopeful I could sort out xplorer² listviews:

and many more

My high hopes were quickly frustrated after I realized (playing with SetWindowTheme) that there is no silver bullet theme. There's the familiar DarkMode_Explorer with its poor color scheme, and DarkMode_ItemsView with a color scheme identical to dark mode windows explorer but with white scrollbars!? Close but no cigar. Themes being the rigid monoliths that they are, you can't take the scrollbars of one and mix them with the highlight colors of the other. Which is the lesser of 2 evils?

dark listview themes
Figure 1. Poor selection colors (left) or white scrollbar? (right)

Had aero themes cared to define DarkMode_ItemsView::ScrollBar (even copy/paste from DarkMode_Explorer::ScrollBar), everything would be perfect. But modifying themes by 3rd party tools isn't really an option, and neither is hooking scrollbar creation — even smartscreen goes bezerk detecting such dodgy code.

All these DarkMode-xxx themes are available from windows 10 onwards. Good luck if you are targetting windows 7 or even older windows versions as well — my lot in life!

Where is Raymond Chen when you need him?

Post a comment on this topic »

©2002-2024 ZABKAT LTD, all rights reserved | Privacy policy | Sitemap