https://stackoverflow.com/questions/39261826/change-the-color-of-the-title-bar-caption-of-a-win32-application https://gist.github.com/rounk-ctrl/b04e5622e30e0d62956870d5c22b7017 https://github.com/microsoft/WindowsAppSDK/issues/41 https://gist.github.com/ericoporto/1745f4b912e22f9eabfce2c7166d979b
| 219 | // https://github.com/microsoft/WindowsAppSDK/issues/41 |
| 220 | // https://gist.github.com/ericoporto/1745f4b912e22f9eabfce2c7166d979b |
| 221 | void EnableDarkMode(HWND hWnd) { |
| 222 | |
| 223 | // apply dark mode to the window |
| 224 | { |
| 225 | const BOOL USE_DARK_MODE = true; |
| 226 | |
| 227 | DwmSetWindowAttribute(hWnd, |
| 228 | DWMWA_USE_IMMERSIVE_DARK_MODE, |
| 229 | &USE_DARK_MODE, |
| 230 | sizeof(USE_DARK_MODE)); |
| 231 | } |
| 232 | |
| 233 | // apply dark mode to the context menus |
| 234 | { |
| 235 | using fnSetPreferredAppMode = PreferredAppMode(WINAPI*)(PreferredAppMode appMode); |
| 236 | fnSetPreferredAppMode SetPreferredAppMode; |
| 237 | |
| 238 | static HMODULE hUxtheme = nullptr; |
| 239 | |
| 240 | if (!hUxtheme) { |
| 241 | hUxtheme = LoadLibraryExW(L"uxtheme.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); |
| 242 | } |
| 243 | |
| 244 | if (hUxtheme) { |
| 245 | // #135 is the ordinal for SetPreferredAppMode private API |
| 246 | // which is available in uxtheme.dll since Windows 10 1903+ |
| 247 | SetPreferredAppMode = (fnSetPreferredAppMode)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(135)); |
| 248 | SetPreferredAppMode(PreferredAppMode::ForceDark); |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | LRESULT CALLBACK CallWndSubClassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData); |
| 254 |
no outgoing calls
no test coverage detected