From 90116239cf776799c66d1cc8f429ad8fc01de95c Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Fri, 21 Oct 2022 09:41:35 +0800 Subject: [PATCH] win: minor tweaks Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- src/core/utils_win.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/utils_win.cpp b/src/core/utils_win.cpp index c8e80b8..bc145d6 100644 --- a/src/core/utils_win.cpp +++ b/src/core/utils_win.cpp @@ -2101,6 +2101,9 @@ void Utils::registerThemeChangeNotification() void Utils::refreshWin32ThemeResources(const WId windowId, const bool dark) { + // Code learned from the following repositories. Thank very much for their great effort! + // https://github.com/ysc3839/win32-darkmode/blob/master/win32-darkmode/DarkMode.h + // https://github.com/TortoiseGit/TortoiseGit/blob/master/src/TortoiseGitBlame/MainFrm.cpp Q_ASSERT(windowId); if (!windowId) { return; @@ -2159,7 +2162,9 @@ void Utils::refreshWin32ThemeResources(const WId windowId, const bool dark) if (GetLastError() != ERROR_SUCCESS) { WARNING << getSystemErrorMessage(kRefreshImmersiveColorPolicyState); } - if (GetIsImmersiveColorUsingHighContrast(IHCM_REFRESH) == FALSE) { + SetLastError(ERROR_SUCCESS); + Q_UNUSED(GetIsImmersiveColorUsingHighContrast(IHCM_REFRESH)); + if (GetLastError() != ERROR_SUCCESS) { WARNING << getSystemErrorMessage(kGetIsImmersiveColorUsingHighContrast); } } else { @@ -2190,7 +2195,9 @@ void Utils::refreshWin32ThemeResources(const WId windowId, const bool dark) if (GetLastError() != ERROR_SUCCESS) { WARNING << getSystemErrorMessage(kRefreshImmersiveColorPolicyState); } - if (GetIsImmersiveColorUsingHighContrast(IHCM_REFRESH) == FALSE) { + SetLastError(ERROR_SUCCESS); + Q_UNUSED(GetIsImmersiveColorUsingHighContrast(IHCM_REFRESH)); + if (GetLastError() != ERROR_SUCCESS) { WARNING << getSystemErrorMessage(kGetIsImmersiveColorUsingHighContrast); } if (WindowsVersionHelper::isWin1019H1OrGreater()) {