https://git.reactos.org/?p=reactos.git;a=commitdiff;h=751641c2bec7ca2ef022f3a3dd89bd2fa09b83d3
commit 751641c2bec7ca2ef022f3a3dd89bd2fa09b83d3 Author: Whindmar Saksit <whinds...@proton.me> AuthorDate: Sat Sep 14 13:07:11 2024 +0200 Commit: GitHub <nore...@github.com> CommitDate: Sat Sep 14 13:07:11 2024 +0200 [SHELL32][COMCTL32][BROWSEUI][EXPLORER] Update color usage on WM_SYSCOLORCHANGE (#7325) --- base/shell/explorer/traywnd.cpp | 6 ++++++ dll/win32/browseui/basebarsite.cpp | 13 ++++++++----- dll/win32/browseui/shellbrowser.cpp | 8 ++++++++ dll/win32/comctl32/rebar.c | 5 +++++ dll/win32/shell32/CDefView.cpp | 25 ++++++++++--------------- dll/win32/shell32/shlfileop.cpp | 1 + 6 files changed, 38 insertions(+), 20 deletions(-) diff --git a/base/shell/explorer/traywnd.cpp b/base/shell/explorer/traywnd.cpp index 868447796fc..ed2acdbfb54 100644 --- a/base/shell/explorer/traywnd.cpp +++ b/base/shell/explorer/traywnd.cpp @@ -2542,6 +2542,11 @@ ChangePos: return (LRESULT) GetStockObject(HOLLOW_BRUSH); } + LRESULT OnSysColorChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + return SendMessageW(m_Rebar, uMsg, wParam, lParam); + } + LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { RECT rcClient; @@ -3403,6 +3408,7 @@ HandleTrayContextMenu: MESSAGE_HANDLER(WM_NCPAINT, OnNcPaint) MESSAGE_HANDLER(WM_NCACTIVATE, OnNcActivate) MESSAGE_HANDLER(WM_CTLCOLORBTN, OnCtlColorBtn) + MESSAGE_HANDLER(WM_SYSCOLORCHANGE, OnSysColorChange) MESSAGE_HANDLER(WM_MOVING, OnMoving) MESSAGE_HANDLER(WM_SIZING, OnSizing) MESSAGE_HANDLER(WM_WINDOWPOSCHANGING, OnWindowPosChanging) diff --git a/dll/win32/browseui/basebarsite.cpp b/dll/win32/browseui/basebarsite.cpp index eee836d846d..e67e9b7e9bd 100644 --- a/dll/win32/browseui/basebarsite.cpp +++ b/dll/win32/browseui/basebarsite.cpp @@ -714,7 +714,8 @@ LRESULT CBaseBarSite::OnCustomDraw(LPNMCUSTOMDRAW pnmcd) REBARBANDINFO info; WCHAR wszTitle[MAX_PATH]; DWORD index; - RECT rt; + UINT pad = GetSystemMetrics(SM_CXEDGE), leftpad = max(pad * 2, 4); + UINT btnw = 20, btnh = 18, btnarea = 1 + btnw + 1; HFONT newFont, oldFont; index = SendMessage(RB_IDTOINDEX, fCurrentActiveBar->fBandID , 0); @@ -722,20 +723,22 @@ LRESULT CBaseBarSite::OnCustomDraw(LPNMCUSTOMDRAW pnmcd) ZeroMemory(wszTitle, sizeof(wszTitle)); DrawEdge(pnmcd->hdc, &pnmcd->rc, EDGE_ETCHED, BF_BOTTOM); // We also resize our close button - ::SetWindowPos(toolbarWnd, HWND_TOP, pnmcd->rc.right - 22, 0, 20, 18, SWP_SHOWWINDOW); + ::SetWindowPos(toolbarWnd, HWND_TOP, pnmcd->rc.right - btnarea, 0, btnw, btnh, SWP_SHOWWINDOW); // Draw the text info.cch = MAX_PATH; info.lpText = wszTitle; - rt = pnmcd->rc; - rt.right -= 24; - rt.left += 2; + RECT rt = pnmcd->rc; + rt.right -= btnarea; + rt.left += leftpad; rt.bottom -= 1; if (FAILED_UNEXPECTEDLY(GetInternalBandInfo(index, &info, RBBIM_TEXT))) return CDRF_SKIPDEFAULT; newFont = GetTitleFont(); if (newFont) oldFont = (HFONT)SelectObject(pnmcd->hdc, newFont); + COLORREF orgclrtxt = SetTextColor(pnmcd->hdc, GetSysColor(COLOR_BTNTEXT)); DrawText(pnmcd->hdc, info.lpText, -1, &rt, DT_SINGLELINE | DT_LEFT | DT_VCENTER); + SetTextColor(pnmcd->hdc, orgclrtxt); SelectObject(pnmcd->hdc, oldFont); DeleteObject(newFont); return CDRF_SKIPDEFAULT; diff --git a/dll/win32/browseui/shellbrowser.cpp b/dll/win32/browseui/shellbrowser.cpp index 219767387cb..eb67209a674 100644 --- a/dll/win32/browseui/shellbrowser.cpp +++ b/dll/win32/browseui/shellbrowser.cpp @@ -613,6 +613,7 @@ public: LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); LRESULT RelayMsgToShellView(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); LRESULT OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnSysColorChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); LRESULT OnClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); LRESULT OnFolderOptions(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); LRESULT OnMapNetworkDrive(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); @@ -664,6 +665,7 @@ public: MESSAGE_HANDLER(WM_DRAWITEM, RelayMsgToShellView) MESSAGE_HANDLER(WM_MENUSELECT, RelayMsgToShellView) MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) + MESSAGE_HANDLER(WM_SYSCOLORCHANGE, OnSysColorChange) COMMAND_ID_HANDLER(IDM_FILE_CLOSE, OnClose) COMMAND_ID_HANDLER(IDM_TOOLS_FOLDEROPTIONS, OnFolderOptions) COMMAND_ID_HANDLER(IDM_TOOLS_MAPNETWORKDRIVE, OnMapNetworkDrive) @@ -3796,6 +3798,12 @@ LRESULT CShellBrowser::OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, return 0; } +LRESULT CShellBrowser::OnSysColorChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) +{ + SHPropagateMessage(m_hWnd, uMsg, wParam, lParam, TRUE); + return 0; +} + LRESULT CShellBrowser::OnClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) { return SendMessage(WM_CLOSE); diff --git a/dll/win32/comctl32/rebar.c b/dll/win32/comctl32/rebar.c index 818ae9948f3..f68c6d5051f 100644 --- a/dll/win32/comctl32/rebar.c +++ b/dll/win32/comctl32/rebar.c @@ -2548,10 +2548,15 @@ REBAR_InsertBandT(REBAR_INFO *infoPtr, INT iIndex, const REBARBANDINFOW *lprbbi, /* initialize band */ memset(lpBand, 0, sizeof(*lpBand)); +#ifdef __REACTOS__ + lpBand->clrFore = infoPtr->clrText == CLR_NONE ? CLR_DEFAULT : infoPtr->clrText; + lpBand->clrBack = infoPtr->clrBk == CLR_NONE ? CLR_DEFAULT : infoPtr->clrBk; +#else lpBand->clrFore = infoPtr->clrText == CLR_NONE ? infoPtr->clrBtnText : infoPtr->clrText; lpBand->clrBack = infoPtr->clrBk == CLR_NONE ? infoPtr->clrBtnFace : infoPtr->clrBk; +#endif lpBand->iImage = -1; REBAR_CommonSetupBand(infoPtr->hwndSelf, lprbbi, lpBand); diff --git a/dll/win32/shell32/CDefView.cpp b/dll/win32/shell32/CDefView.cpp index 61bc1581234..771576222fc 100644 --- a/dll/win32/shell32/CDefView.cpp +++ b/dll/win32/shell32/CDefView.cpp @@ -212,6 +212,11 @@ static UINT CalculateCharWidth(HWND hwnd) return ret; } +static inline COLORREF GetViewColor(COLORREF Clr, UINT SysFallback) +{ + return Clr != CLR_INVALID ? Clr : GetSysColor(SysFallback); +} + class CDefView : public CWindowImpl<CDefView, CWindow, CControlWinTraits>, public CComObjectRootEx<CComMultiThreadModelNoCS>, @@ -592,8 +597,8 @@ CDefView::CDefView() : ZeroMemory(&m_FolderSettings, sizeof(m_FolderSettings)); ZeroMemory(&m_ptLastMousePos, sizeof(m_ptLastMousePos)); ZeroMemory(&m_Category, sizeof(m_Category)); - m_viewinfo_data.clrText = GetSysColor(COLOR_WINDOWTEXT); - m_viewinfo_data.clrTextBack = GetSysColor(COLOR_WINDOW); + m_viewinfo_data.clrText = CLR_INVALID; + m_viewinfo_data.clrTextBack = CLR_INVALID; m_viewinfo_data.hbmBack = NULL; m_sortInfo.Reset(); @@ -934,18 +939,8 @@ void CDefView::UpdateListColors() } else { - // text background color - COLORREF clrTextBack = m_viewinfo_data.clrTextBack; - m_ListView.SetTextBkColor(clrTextBack); - - // text color - COLORREF clrText; - if (m_viewinfo_data.clrText != CLR_INVALID) - clrText = m_viewinfo_data.clrText; - else - clrText = GetSysColor(COLOR_WINDOWTEXT); - - m_ListView.SetTextColor(clrText); + m_ListView.SetTextBkColor(GetViewColor(m_viewinfo_data.clrTextBack, COLOR_WINDOW)); + m_ListView.SetTextColor(GetViewColor(m_viewinfo_data.clrText, COLOR_WINDOWTEXT)); // Background is painted by the parent via WM_PRINTCLIENT m_ListView.SetExtendedListViewStyle(LVS_EX_TRANSPARENTBKGND, LVS_EX_TRANSPARENTBKGND); @@ -1663,7 +1658,7 @@ LRESULT CDefView::OnPrintClient(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b } else { - FillRect(hDC, &rc, GetSysColorBrush(COLOR_WINDOW)); + SHFillRectClr(hDC, &rc, GetViewColor(m_viewinfo_data.clrTextBack, COLOR_WINDOW)); } bHandled = TRUE; diff --git a/dll/win32/shell32/shlfileop.cpp b/dll/win32/shell32/shlfileop.cpp index 5e1309aabdf..9600add7517 100644 --- a/dll/win32/shell32/shlfileop.cpp +++ b/dll/win32/shell32/shlfileop.cpp @@ -129,6 +129,7 @@ static INT_PTR ConfirmMsgBox_Paint(HWND hDlg) BeginPaint(hDlg, &ps); hdc = ps.hdc; SetBkMode(hdc, TRANSPARENT); + SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT)); GetClientRect(GetDlgItem(hDlg, IDC_YESTOALL_MESSAGE), &r); /* this will remap the rect to dialog coords */