From 668c2342076e76c7755c275b90276a07979bf387 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Thu, 17 Feb 2022 23:06:24 +0200 Subject: [PATCH] Weather: Support for high contrast themes --- ExplorerPatcher/dllmain.c | 2 +- ep_weather_host/ep_weather_host.c | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 4636d9f..e407bf1 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -4207,7 +4207,7 @@ __int64 __fastcall PeopleBand_DrawTextWithGlowHook( } else { - rgbColor = GetSysColor(COLOR_WINDOWTEXT); + rgbColor = GetSysColor(COLOR_BTNTEXT); } HFONT hOldFont = SelectFont(hDC, hFont); if (bEmptyData) diff --git a/ep_weather_host/ep_weather_host.c b/ep_weather_host/ep_weather_host.c index 87b0731..30979ed 100644 --- a/ep_weather_host/ep_weather_host.c +++ b/ep_weather_host/ep_weather_host.c @@ -789,6 +789,24 @@ LRESULT CALLBACK epw_Weather_WindowProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPA { if (IsColorSchemeChangeMessage(lParam)) { + MARGINS marGlassInset; + if (!IsHighContrast()) + { + marGlassInset.cxLeftWidth = -1; // -1 means the whole window + marGlassInset.cxRightWidth = -1; + marGlassInset.cyBottomHeight = -1; + marGlassInset.cyTopHeight = -1; + } + else + { + marGlassInset.cxLeftWidth = 0; + marGlassInset.cxRightWidth = 0; + marGlassInset.cyBottomHeight = 0; + marGlassInset.cyTopHeight = 0; + } + DwmExtendFrameIntoClientArea(_this->hWnd, &marGlassInset); + BOOL value = (IsThemeActive() && !IsHighContrast()) ? 1 : 0; + DwmSetWindowAttribute(hWnd, 1029, &value, sizeof(BOOL)); LONG64 dwDarkMode = InterlockedAdd64(&_this->g_darkModeEnabled, 0); if (!dwDarkMode) { @@ -990,10 +1008,13 @@ DWORD WINAPI epw_Weather_MainThread(EPWeather* _this) goto cleanup; } - MARGINS marGlassInset = { -1, -1, -1, -1 }; // -1 means the whole window - DwmExtendFrameIntoClientArea(_this->hWnd, &marGlassInset); - BOOL value = 1; - DwmSetWindowAttribute(_this->hWnd, 1029, &value, sizeof(BOOL)); + if (!IsHighContrast()) + { + MARGINS marGlassInset = { -1, -1, -1, -1 }; // -1 means the whole window + DwmExtendFrameIntoClientArea(_this->hWnd, &marGlassInset); + BOOL value = 1; + DwmSetWindowAttribute(_this->hWnd, 1029, &value, sizeof(BOOL)); + } LONG64 dwDarkMode = InterlockedAdd64(&_this->g_darkModeEnabled, 0); epw_Weather_SetDarkMode(_this, dwDarkMode, FALSE);