From 1e5f288a9f92bc37f5fded0fc8be399aabb25954 Mon Sep 17 00:00:00 2001 From: okrc Date: Thu, 1 Dec 2022 09:44:26 +0800 Subject: [PATCH] added dark TitleBar for supported versions of Windows 10 --- SandboxiePlus/SandMan/SandMan.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index 8cc6b27f..46484cd5 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -2994,9 +2994,9 @@ void CSandMan::SetTitleTheme(const HWND& hwnd) { static const int CurrentVersion = QSettings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", QSettings::NativeFormat).value("CurrentBuild").toInt(); - if (CurrentVersion < 22000) // Windows 11- + if (CurrentVersion < 17763) // Windows 10 1809 - return; - + HMODULE dwmapi = GetModuleHandle(L"dwmapi.dll"); if (dwmapi) { @@ -3004,11 +3004,17 @@ void CSandMan::SetTitleTheme(const HWND& hwnd) P_DwmSetWindowAttribute pDwmSetWindowAttribute = reinterpret_cast(GetProcAddress(dwmapi, "DwmSetWindowAttribute")); if (pDwmSetWindowAttribute) { +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 +#define DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 19 +#endif #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 #endif - BOOL value = m_DarkTheme; - pDwmSetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(value)); + BOOL bDark = m_DarkTheme; + pDwmSetWindowAttribute(hwnd, + CurrentVersion >= 18985 ? DWMWA_USE_IMMERSIVE_DARK_MODE : DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1, + &bDark, + sizeof(bDark)); } } }