microsoft / microsoft/WindowsAppSDK
Feature Request: API to detect dark mode
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 471
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 28
Description
To this date, there is no proper API to detect whether dark mode is enabled in Windows.
The proposed API must provide:
* Selected _app mode_ theme
* Notifications when the selected _app mode_ theme changes
* Selected _system mode_ theme
* Notifications when the selected _system mode_ theme changes
It is important to also detect system mode themes, for example to be able to change the NotifyIcon icon color depending on the Windows taskbar theme.
The proposed API should also provide:
* Whether high contrast mode is enabled
* Which high contrast mode is set
* Notifications when high contrast mode changes
(these are already provided with WinRT [AccessibilitySettings](https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.accessibilitysettings.highcontrast), but could be added to a new Windows App SDK API as well).
Currently, there are only multiple workarounds, which are either undocumented or flawed:
* [UISettings.GetColorValue() with a formula to detect if the color is light](https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/ui/apply-windows-themes#know-when-dark-mode-is-enabled) - documented, but hacky formula and does not provide system mode theme
* `ShouldAppsUseDarkMode` and `ShouldSystemUseDarkMode` in `uxtheme.dll` - undocumented, but work fine otherwise
* `HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize` `AppsUseLightTheme` & `SystemUsesLightTheme` - undocumented, but work fine otherwise
There was already an issue on GitHub, #5476 "Dark mode for applications", but it was closed even though the issue is not yet resolved. I am opening this issue to avoid the issue getting lost.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the related issue #5476 and the listed UISettings, uxtheme.dll, registry, and AccessibilitySettings approaches. Compare the requested app-mode, system-mode, high-contrast, and change-notification requirements with the existing Windows App SDK API surface. Done means an agreed API scope and implementation path, not merely another workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- accessibility, api, desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100