Support system wide dark theme on Windows. Right now, when I use dark mode on Windows, the window title border and menu are still light.
Unfortunately this is currently not possible. Microsoft only exposes the dark mode to apps written using their UWP APIs. Sublime Text is a Win32 app. UWP apps only run on Windows 10, and are structured much differently.
Hopefully in a future Windows 10 release Microsoft will provide a way for Win32 apps to query the state of dark mode to allow us to integrate with it.
Microsoft just would need to provide a uxtheme based Dark Theme for win32 apps to globally support dark mode for all kind of applications. But I guess their mess of GUI fragments became too … to properly maintain it.
If I enable Dark Mode on Windows I’d expect any dialog/window/control/… to be rendered in dark mode, not just the UWP and WFP apps.
This is something app developers shouldn’t need do be bothered with.
Well, since we are here on the Sublime Text forum, and Sublime Text has 100% custom rendering of everything but the non-client areas, then yes it is still relevant.
Either way, this is a topic I keep my eye out for news of. I imagine at some point they’ll at least make it possible to query and/or opt into dark mode in the non-client areas. It took quite a few Windows 10 releases for high-DPI to become fully baked, so I would expect a similar process here, if it ever does happen.
Well, as ST uses the OS’s default none-client area controls to render the main menu and titlebar, it’s up to the OS to apply a proper theme.
Same for the context and dropdown menues which are native OS controls or the open/save dialogs which need to be handled by the OS’s theme engine as well.
An API to modify the titlebar color wouldn’t be useful if the OS would still render light context menus or dialogs due to missing dark theme support for them.
The following screenshot should illustrate what I mean. Without any modification from the application side a proper uxtheme based theme would enable all win32 applications to look well in most situations as long as they use colors defined by a theme instead of hardcoded ones.
I just patched the uxtheme dlls and installed the custom After Dark CC Theme For Windows 10 RTM theme to enable all win32 applications to support the dark mode.
A bit dangerous though as the ongoing windows backend changes quickly render such a theme incompatible and as a result may render the whole desktop unusable.
The custom controls of GitExtensions behave a bit strange here and there, but ok.
According to this SO, it can be pulled from the registry:
That screenshot looks fantastic!
The issue is not how to detect dark mode, but how to make use of it. All plain win32 applications (no .NET!, UWP, WPF) run within the legacy window frame which uses the uxtheme based themeing from Windows XP. There is no API to modify those elements. This is what I mean with Microsoft being responsible to provide a proper dark mode theme for such kind of apps. Not sure whether they are willing to do so.
I am sure they are willing to do, but it may take very long. So basically currently Explorer is the only win32 app that supports dark mode via undocumented magic? Okay… we will wait with patience.
Windows Explorer is an UWP or WPF application. It makes use of the “new” Windows runtime.
I was responding to dbond saying “Hopefully in a future Windows 10 release Microsoft will provide a way for Win32 apps to query the state of dark mode to allow us to integrate with it.” (emphasis mine)
Querying is possible now.
Also, Win32 apps can custom draw everything if they want to. Remember the winamp music player in the 90’s?
The details on custom drawing are readily found on the web.
Waiting for Microsoft is questionable. They may never provide default dark mode for win32 gui components either due to lack of interest or because of bona fide technical issues.
Why remember? Everything but the menues (main or context) and windows titlebar is custom rendered.
The only option to support dark menus was to create custom controls for them. In that case those would propably support ST like theming and thus would look like the rest of the app by nature. No need for dedicated dark mode support then.
The only thing the “dark mode query” would be able to offer was a way to select either a dark or light theme then.
Indeed only the menues are left white, and hiding them is a simple and elegant solution that ST already offers. Not only this leaves ST dark, it offers extra screen space as well.
Pressing alt will bring them back. I rarely use the menu these days though anyway…
i red all the comment its was very helpful thank you sooo much
Spoken English Advance
Wrote this plugin:
You guys probably saw these links:
DHowett-MSFT had an interesting comment in issue 3425: watch this space.
In the meantime, you can always force Sublime to have a dark title bar via an external app. There’s nothing to do about the Menu bar, though.
@wbond Possibly a more applicable solution would be this, as it does not rely on private APIs that may change. Some additional code however may need to be added so that the custom window title is not applied to OS’s below Windows 10.
We don’t use WPF for Sublime products - just win32.
Unless Microsoft adds an API for custom title bars, the issue will have to wait until a time when we decide that writing all of the custom non-client area drawing, event handling and menu handling is worth it.
Looking at both of these issues, I wonder if they will just tell Win32 app devs to add a XamlIsland for titlebar customizations once they add it to Project Reunion (WinUI). Kind of a bummer.
If you draw your own titlebar, do you really have to owner-draw the menu control as well?
I am not an expert, but I think you have to draw your own menu bar - hence why many apps move to a hamburger menu. If you want a dark menu you’ve have to draw the menu itself too.