Merge pull request #2509 from okrc/master

added dark TitleBar for supported versions of Windows 10
This commit is contained in:
DavidXanatos 2022-12-01 15:47:29 +01:00 committed by GitHub
commit 3408d3d6ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -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<P_DwmSetWindowAttribute>(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));
}
}
}