From 3f67f7065ce403185ed74c4a01a02dded973e783 Mon Sep 17 00:00:00 2001 From: Dart Vanya Date: Tue, 17 Dec 2024 23:40:51 +0300 Subject: [PATCH] chcol ListBox fix dynamic theme switching --- SystemInformer/chcol.c | 40 ++++++++++++++++++-------------- phlib/colorbox.c | 4 ++-- plugins/ToolStatus/customizesb.c | 37 +++++++++++++++-------------- plugins/ToolStatus/customizetb.c | 40 ++++++++++++++++++-------------- plugins/ToolStatus/toolstatus.h | 4 ++++ 5 files changed, 70 insertions(+), 55 deletions(-) diff --git a/SystemInformer/chcol.c b/SystemInformer/chcol.c index d13769a375a2..d3365a4a06da 100644 --- a/SystemInformer/chcol.c +++ b/SystemInformer/chcol.c @@ -24,6 +24,10 @@ typedef struct _COLUMNS_DIALOG_CONTEXT HBRUSH BrushPushed; HBRUSH BrushHot; COLORREF TextColor; + HBRUSH BrushNormalDark; + HBRUSH BrushPushedDark; + HBRUSH BrushHotDark; + COLORREF TextColorDark; HWND InactiveWindowHandle; HWND ActiveWindowHandle; @@ -256,20 +260,15 @@ INT_PTR CALLBACK PhpColumnsDlgProc( Button_Enable(context->MoveUpHandle, FALSE); Button_Enable(context->MoveDownHandle, FALSE); - if (PhEnableThemeSupport) - { - context->BrushNormal = CreateSolidBrush(PhThemeWindowBackgroundColor); - context->BrushHot = CreateSolidBrush(PhThemeWindowHighlightColor); - context->BrushPushed = CreateSolidBrush(PhThemeWindowHighlight2Color); - context->TextColor = PhThemeWindowTextColor; - } - else - { - context->BrushNormal = GetSysColorBrush(COLOR_WINDOW); - context->BrushHot = CreateSolidBrush(RGB(145, 201, 247)); - context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255)); - context->TextColor = GetSysColor(COLOR_WINDOWTEXT); - } + context->BrushNormal = GetSysColorBrush(COLOR_WINDOW); + context->BrushHot = CreateSolidBrush(RGB(145, 201, 247)); + context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255)); + context->TextColor = GetSysColor(COLOR_WINDOWTEXT); + + context->BrushNormalDark = CreateSolidBrush(PhThemeWindowBackgroundColor); + context->BrushHotDark = CreateSolidBrush(PhThemeWindowHighlightColor); + context->BrushPushedDark = CreateSolidBrush(PhThemeWindowHighlight2Color); + context->TextColorDark = PhThemeWindowTextColor; if (context->Type == PH_CONTROL_TYPE_TREE_NEW) { @@ -356,6 +355,12 @@ INT_PTR CALLBACK PhpColumnsDlgProc( DeleteBrush(context->BrushHot); if (context->BrushPushed) DeleteBrush(context->BrushPushed); + if (context->BrushNormalDark) + DeleteBrush(context->BrushNormalDark); + if (context->BrushHotDark) + DeleteBrush(context->BrushHotDark); + if (context->BrushPushedDark) + DeleteBrush(context->BrushPushedDark); if (context->ControlFont) DeleteFont(context->ControlFont); if (context->InactiveListArray) @@ -693,16 +698,15 @@ INT_PTR CALLBACK PhpColumnsDlgProc( if (isSelected || isFocused) { - FillRect(bufferDc, &bufferRect, context->BrushHot); + FillRect(bufferDc, &bufferRect, PhEnableThemeSupport ? context->BrushHotDark : context->BrushHot); //FrameRect(bufferDc, &bufferRect, PhGetStockBrush(BLACK_BRUSH)); - SetTextColor(bufferDc, context->TextColor); } else { - FillRect(bufferDc, &bufferRect, context->BrushNormal); + FillRect(bufferDc, &bufferRect, PhEnableThemeSupport ? context->BrushNormalDark : context->BrushNormal); //FrameRect(bufferDc, &bufferRect, GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); - SetTextColor(bufferDc, context->TextColor); } + SetTextColor(bufferDc, PhEnableThemeSupport ? context->TextColorDark : context->TextColor); bufferRect.left += 5; DrawText( diff --git a/phlib/colorbox.c b/phlib/colorbox.c index e7c773d7e24b..31cc576e46e0 100644 --- a/phlib/colorbox.c +++ b/phlib/colorbox.c @@ -94,8 +94,8 @@ UINT_PTR CALLBACK PhpColorBoxDlgHookProc( PhCenterWindow(hwndDlg, GetParent(hwndDlg)); - if (context->EnableThemeSupport) - PhInitializeWindowThemeEx(hwndDlg, TRUE); + //if (context->EnableThemeSupport) + PhInitializeWindowTheme(hwndDlg); } break; case WM_CTLCOLORBTN: diff --git a/plugins/ToolStatus/customizesb.c b/plugins/ToolStatus/customizesb.c index afba48d6b5f9..7ff1e11a3513 100644 --- a/plugins/ToolStatus/customizesb.c +++ b/plugins/ToolStatus/customizesb.c @@ -290,21 +290,15 @@ INT_PTR CALLBACK CustomizeStatusBarDialogProc( context->WindowDpi = PhGetWindowDpi(hwndDlg); context->FontHandle = PhCreateIconTitleFont(context->WindowDpi); - if (PhIsThemeSupportEnabled()) - { - context->BrushNormal = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowBackgroundColor")); - context->BrushHot = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlightColor")); - context->BrushPushed = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlight2Color")); - context->TextColor = PhGetIntegerSetting(L"ThemeWindowTextColor"); - } - else - { - context->BrushNormal = GetSysColorBrush(COLOR_WINDOW); - context->BrushHot = CreateSolidBrush(RGB(145, 201, 247)); - context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255)); - context->TextColor = GetSysColor(COLOR_WINDOWTEXT); - } + context->BrushNormal = GetSysColorBrush(COLOR_WINDOW); + context->BrushHot = CreateSolidBrush(RGB(145, 201, 247)); + context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255)); + context->TextColor = GetSysColor(COLOR_WINDOWTEXT); + context->BrushNormalDark = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowBackgroundColor")); + context->BrushHotDark = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlightColor")); + context->BrushPushedDark = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlight2Color")); + context->TextColorDark = PhGetIntegerSetting(L"ThemeWindowTextColor"); ListBox_SetItemHeight(context->AvailableListHandle, 0, PhGetDpi(22, context->WindowDpi)); // BitmapHeight ListBox_SetItemHeight(context->CurrentListHandle, 0, PhGetDpi(22, context->WindowDpi)); // BitmapHeight @@ -331,6 +325,15 @@ INT_PTR CALLBACK CustomizeStatusBarDialogProc( if (context->BrushPushed) DeleteBrush(context->BrushPushed); + if (context->BrushNormalDark) + DeleteBrush(context->BrushNormalDark); + + if (context->BrushHotDark) + DeleteBrush(context->BrushHotDark); + + if (context->BrushPushedDark) + DeleteBrush(context->BrushPushedDark); + if (context->FontHandle) DeleteFont(context->FontHandle); } @@ -595,12 +598,12 @@ INT_PTR CALLBACK CustomizeStatusBarDialogProc( SetBkMode(bufferDc, TRANSPARENT); if (isSelected || isFocused) - FillRect(bufferDc, &bufferRect, context->BrushHot); + FillRect(bufferDc, &bufferRect, PhIsThemeSupportEnabled() ? context->BrushHotDark : context->BrushHot); else - FillRect(bufferDc, &bufferRect, context->BrushNormal); + FillRect(bufferDc, &bufferRect, PhIsThemeSupportEnabled() ? context->BrushNormalDark : context->BrushNormal); if (!button->IsVirtual) - SetTextColor(bufferDc, context->TextColor); + SetTextColor(bufferDc, PhIsThemeSupportEnabled() ? context->TextColorDark : context->TextColor); else SetTextColor(bufferDc, GetSysColor(COLOR_GRAYTEXT)); diff --git a/plugins/ToolStatus/customizetb.c b/plugins/ToolStatus/customizetb.c index 7c67bb8addd4..32a158f36be1 100644 --- a/plugins/ToolStatus/customizetb.c +++ b/plugins/ToolStatus/customizetb.c @@ -514,20 +514,15 @@ INT_PTR CALLBACK CustomizeToolbarDialogProc( context->FontHandle = PhCreateIconTitleFont(context->WindowDpi); context->CXWidth = PhGetDpi(16, context->WindowDpi); - if (PhIsThemeSupportEnabled()) - { - context->BrushNormal = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowBackgroundColor")); - context->BrushHot = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlightColor")); - context->BrushPushed = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlight2Color")); - context->TextColor = PhGetIntegerSetting(L"ThemeWindowTextColor"); - } - else - { - context->BrushNormal = GetSysColorBrush(COLOR_WINDOW); - context->BrushHot = CreateSolidBrush(RGB(145, 201, 247)); - context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255)); - context->TextColor = GetSysColor(COLOR_WINDOWTEXT); - } + context->BrushNormal = GetSysColorBrush(COLOR_WINDOW); + context->BrushHot = CreateSolidBrush(RGB(145, 201, 247)); + context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255)); + context->TextColor = GetSysColor(COLOR_WINDOWTEXT); + + context->BrushNormalDark = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowBackgroundColor")); + context->BrushHotDark = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlightColor")); + context->BrushPushedDark = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlight2Color")); + context->TextColorDark = PhGetIntegerSetting(L"ThemeWindowTextColor"); ListBox_SetItemHeight(context->AvailableListHandle, 0, context->CXWidth + 6); // BitmapHeight ListBox_SetItemHeight(context->CurrentListHandle, 0, context->CXWidth + 6); // BitmapHeight @@ -555,6 +550,15 @@ INT_PTR CALLBACK CustomizeToolbarDialogProc( if (context->BrushPushed) DeleteBrush(context->BrushPushed); + if (context->BrushNormalDark) + DeleteBrush(context->BrushNormalDark); + + if (context->BrushHotDark) + DeleteBrush(context->BrushHotDark); + + if (context->BrushPushedDark) + DeleteBrush(context->BrushPushedDark); + if (context->FontHandle) DeleteFont(context->FontHandle); } @@ -888,13 +892,13 @@ INT_PTR CALLBACK CustomizeToolbarDialogProc( SelectFont(bufferDc, context->FontHandle); SetBkMode(bufferDc, TRANSPARENT); - if (isFocused || isSelected) - FillRect(bufferDc, &bufferRect, context->BrushHot); + if (isSelected || isFocused) + FillRect(bufferDc, &bufferRect, PhIsThemeSupportEnabled() ? context->BrushHotDark : context->BrushHot); else - FillRect(bufferDc, &bufferRect, context->BrushNormal); + FillRect(bufferDc, &bufferRect, PhIsThemeSupportEnabled() ? context->BrushNormalDark : context->BrushNormal); if (!itemContext->IsVirtual) - SetTextColor(bufferDc, context->TextColor); + SetTextColor(bufferDc, PhIsThemeSupportEnabled() ? context->TextColorDark : context->TextColor); else SetTextColor(bufferDc, GetSysColor(COLOR_GRAYTEXT)); diff --git a/plugins/ToolStatus/toolstatus.h b/plugins/ToolStatus/toolstatus.h index 5772e003abc5..4926beb9ae80 100644 --- a/plugins/ToolStatus/toolstatus.h +++ b/plugins/ToolStatus/toolstatus.h @@ -474,6 +474,10 @@ typedef struct _CUSTOMIZE_CONTEXT HBRUSH BrushPushed; HBRUSH BrushHot; COLORREF TextColor; + HBRUSH BrushNormalDark; + HBRUSH BrushPushedDark; + HBRUSH BrushHotDark; + COLORREF TextColorDark; LONG WindowDpi; INT CXWidth;