From a027eb7ccbe224af371db84f4b7c5015ca520985 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Sat, 25 Mar 2023 21:31:32 +0900 Subject: [PATCH] [EXPLORER] Improve Clock text color for High Contrast (#5180) Use GetSysColor(COLOR_BTNTEXT) to get the system color in CTrayClockWnd::OnPaint. CORE-18886 --- base/shell/explorer/trayclock.cpp | 35 ++++++++----------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/base/shell/explorer/trayclock.cpp b/base/shell/explorer/trayclock.cpp index 5286aad774e..8aaddca02a8 100644 --- a/base/shell/explorer/trayclock.cpp +++ b/base/shell/explorer/trayclock.cpp @@ -150,11 +150,11 @@ public: CTrayClockWnd::CTrayClockWnd() : hFont(NULL), + textColor(0), dwFlags(0), LineSpacing(0), VisibleLines(0) { - ZeroMemory(&textColor, sizeof(textColor)); ZeroMemory(&rcText, sizeof(rcText)); ZeroMemory(&LocalTime, sizeof(LocalTime)); ZeroMemory(&CurrentSize, sizeof(CurrentSize)); @@ -173,34 +173,19 @@ LRESULT CTrayClockWnd::OnThemeChanged() if (clockTheme) { - GetThemeFont(clockTheme, - NULL, - CLP_TIME, - 0, - TMT_FONT, - &clockFont); + GetThemeFont(clockTheme, NULL, CLP_TIME, 0, TMT_FONT, &clockFont); hFont = CreateFontIndirectW(&clockFont); - GetThemeColor(clockTheme, - CLP_TIME, - 0, - TMT_TEXTCOLOR, - &textColor); + GetThemeColor(clockTheme, CLP_TIME, 0, TMT_TEXTCOLOR, &textColor); if (this->hFont != NULL) DeleteObject(this->hFont); SetFont(hFont, FALSE); - } - else - { - /* We don't need to set a font here, our parent will use - * WM_SETFONT to set the right one when themes are not enabled. */ - textColor = RGB(0, 0, 0); - } - CloseThemeData(clockTheme); + CloseThemeData(clockTheme); + } return TRUE; } @@ -520,14 +505,11 @@ LRESULT CTrayClockWnd::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH HFONT hPrevFont; INT iPrevBkMode; UINT i, line; - PAINTSTRUCT ps; HDC hDC = (HDC) wParam; if (wParam == 0) - { hDC = BeginPaint(&ps); - } if (hDC == NULL) return FALSE; @@ -537,7 +519,10 @@ LRESULT CTrayClockWnd::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH { iPrevBkMode = SetBkMode(hDC, TRANSPARENT); - SetTextColor(hDC, textColor); + if (!IsAppThemed()) + textColor = ::GetSysColor(COLOR_BTNTEXT); + + ::SetTextColor(hDC, textColor); hPrevFont = (HFONT) SelectObject(hDC, hFont); @@ -567,9 +552,7 @@ LRESULT CTrayClockWnd::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH } if (wParam == 0) - { EndPaint(&ps); - } return TRUE; }