Skip to content

Commit

Permalink
chcol ListBox fix dynamic theme switching
Browse files Browse the repository at this point in the history
  • Loading branch information
DartVanya committed Dec 18, 2024
1 parent 3971519 commit e4210cb
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 73 deletions.
40 changes: 22 additions & 18 deletions SystemInformer/chcol.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions phlib/colorbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 4 additions & 18 deletions phlib/theme.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,7 @@ BOOLEAN CALLBACK PhpThemeWindowEnumChildWindows(
}
else if (PhEqualStringZ(windowClassName, L"RICHEDIT50W", FALSE))
{
if (enableThemeSupport && PhEnableThemeListviewBorder)
PhSetWindowStyle(WindowHandle, WS_BORDER, WS_BORDER);
else if (enableThemeSupport)
PhSetWindowStyle(WindowHandle, WS_BORDER, 0);
PhSetWindowStyle(WindowHandle, WS_BORDER, enableThemeSupport && !PhEnableThemeListviewBorder ? 0 : WS_BORDER);

SetWindowPos(WindowHandle, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);

Expand Down Expand Up @@ -842,10 +839,7 @@ VOID PhInitializeTreeNewTheme(
// ToolTip theme is applied automatically by phlib delayhook.c (Dart Vanya)
}

if (EnableThemeSupport && PhEnableThemeListviewBorder)
PhSetWindowExStyle(TreeNewHandle, WS_EX_CLIENTEDGE, WS_EX_CLIENTEDGE);
else if (EnableThemeSupport)
PhSetWindowExStyle(TreeNewHandle, WS_EX_CLIENTEDGE, 0);
PhSetWindowExStyle(TreeNewHandle, WS_EX_CLIENTEDGE, EnableThemeSupport && !PhEnableThemeListviewBorder ? 0 : WS_EX_CLIENTEDGE);

SetWindowPos(TreeNewHandle, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);

Expand All @@ -868,16 +862,8 @@ VOID PhInitializeListViewTheme(
// ToolTip theme is applied automatically by phlib delayhook.c (Dart Vanya)
}

if (EnableThemeSupport && PhEnableThemeListviewBorder)
{
PhSetWindowStyle(ListViewHandle, WS_BORDER, WS_BORDER);
PhSetWindowExStyle(ListViewHandle, WS_EX_CLIENTEDGE, WS_EX_CLIENTEDGE);
}
else if (EnableThemeSupport)
{
PhSetWindowStyle(ListViewHandle, WS_BORDER, 0);
PhSetWindowExStyle(ListViewHandle, WS_EX_CLIENTEDGE, 0);
}
PhSetWindowStyle(ListViewHandle, WS_BORDER, EnableThemeSupport && !PhEnableThemeListviewBorder ? 0 : WS_BORDER);
PhSetWindowExStyle(ListViewHandle, WS_EX_CLIENTEDGE, EnableThemeSupport && !PhEnableThemeListviewBorder ? 0 : WS_EX_CLIENTEDGE);

SetWindowPos(ListViewHandle, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);

Expand Down
37 changes: 20 additions & 17 deletions plugins/ToolStatus/customizesb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand Down Expand Up @@ -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));

Expand Down
40 changes: 22 additions & 18 deletions plugins/ToolStatus/customizetb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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));

Expand Down
4 changes: 4 additions & 0 deletions plugins/ToolStatus/toolstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e4210cb

Please sign in to comment.