From 0e63937ce3ec5af17e5fe2acb4d0adb18782ee2a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 25 Nov 2016 21:55:15 +0300 Subject: WM_CTLCOLORSTATIC handler moved to mir_core.dll --- include/m_gui.h | 3 ++- src/mir_app/src/colorchooser.cpp | 11 ++--------- src/mir_app/src/options.cpp | 11 ++--------- src/mir_app/src/profilemanager.cpp | 14 -------------- src/mir_app/src/proto_opts.cpp | 15 +++++---------- src/mir_core/src/ui_utils.cpp | 10 ++++++++++ 6 files changed, 21 insertions(+), 43 deletions(-) diff --git a/include/m_gui.h b/include/m_gui.h index f09e249517..977939bba2 100644 --- a/include/m_gui.h +++ b/include/m_gui.h @@ -491,6 +491,7 @@ public: __forceinline CDlgBase *GetParent() { return m_parentWnd; } __forceinline bool IsChanged() const { return m_bChanged; } __forceinline void SetSilent() { m_bSilent = true; } + __forceinline void UseSystemColors() { m_bUseSystemColors = true; } void Enable(int bIsEnable = true); __forceinline void Disable() { Enable(false); } @@ -529,7 +530,7 @@ protected: HWND m_hwnd; // must be the first data item int m_idCtrl; CDlgBase* m_parentWnd; - bool m_bChanged, m_bSilent; + bool m_bChanged, m_bSilent, m_bUseSystemColors; public: CCallback OnChange; diff --git a/src/mir_app/src/colorchooser.cpp b/src/mir_app/src/colorchooser.cpp index f414bec570..2cde79322b 100644 --- a/src/mir_app/src/colorchooser.cpp +++ b/src/mir_app/src/colorchooser.cpp @@ -78,6 +78,8 @@ public: RECT rc; GetWindowRect(hwndChooser, &rc); + m_text.UseSystemColors(); + m_hwndParent = hwndDlg; m_hwndTarget = hwndTarget; m_pModule = chatApi.MM_FindModule(si->pszModule); @@ -115,15 +117,6 @@ public: virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override { switch (msg) { - case WM_CTLCOLOREDIT: - case WM_CTLCOLORSTATIC: - if ((HWND)lParam == m_text.GetHwnd()) { - SetTextColor((HDC)wParam, RGB(60, 60, 150)); - SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); - return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); - } - break; - case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: diff --git a/src/mir_app/src/options.cpp b/src/mir_app/src/options.cpp index 1c0505ea21..fbafdd2b11 100644 --- a/src/mir_app/src/options.cpp +++ b/src/mir_app/src/options.cpp @@ -728,6 +728,8 @@ public: m_szTab(pszTab), m_pages(arPages) { + m_keywordFilter.UseSystemColors(); + m_pageTree.OnSelChanging = Callback(this, &COptionsDlg::OnChanging); m_pageTree.OnSelChanged = Callback(this, &COptionsDlg::OnTreeChanged); @@ -1040,15 +1042,6 @@ public: virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override { switch (msg) { - case WM_CTLCOLORSTATIC: - switch (GetDlgCtrlID((HWND)lParam)) { - case IDC_WHITERECT: - case IDC_KEYWORD_FILTER: - SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); - return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); - } - break; - case HM_MODULELOAD: LoadOptionsModule((HINSTANCE)lParam); break; diff --git a/src/mir_app/src/profilemanager.cpp b/src/mir_app/src/profilemanager.cpp index 0c24f1738c..9790a5cae3 100644 --- a/src/mir_app/src/profilemanager.cpp +++ b/src/mir_app/src/profilemanager.cpp @@ -620,20 +620,6 @@ public: } } - virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) - { - switch (msg) { - case WM_CTLCOLORSTATIC: - switch (GetDlgCtrlID((HWND)lParam)) { - case IDC_WHITERECT: - SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); - return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); - } - break; - } - return CDlgBase::DlgProc(msg, wParam, lParam); - } - virtual void OnDestroy() { LRESULT curSel = m_servicePlugs.GetCurSel(); diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index 7464d0b6ff..4b49f22ed5 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -269,6 +269,7 @@ class CAccountManagerDlg : public CDlgBase CAccountListCtrl m_accList; CCtrlButton m_btnAdd, m_btnEdit, m_btnUpgrade, m_btnRemove, m_btnOptions, m_btnNetwork; CCtrlButton m_btnOk, m_btnCancel; + CCtrlBase m_name; void ClickButton(CCtrlButton &btn) { @@ -346,6 +347,7 @@ public: CAccountManagerDlg() : CDlgBase(g_hInst, IDD_ACCMGR), m_accList(this, IDC_ACCLIST), + m_name(this, IDC_NAME), m_btnOk(this, IDOK), m_btnAdd(this, IDC_ADD), m_btnEdit(this, IDC_EDIT), @@ -355,6 +357,8 @@ public: m_btnOptions(this, IDC_OPTIONS), m_btnNetwork(this, IDC_LNK_NETWORK) { + m_name.UseSystemColors(); + m_accList.OnDblClick = Callback(this, &CAccountManagerDlg::OnListDblClick); m_accList.OnSelChange = Callback(this, &CAccountManagerDlg::OnListSelChange); m_accList.OnBuildMenu = Callback(this, &CAccountManagerDlg::OnListMenu); @@ -408,7 +412,7 @@ public: m_normalHeight = 4 + max(m_titleHeight, g_iIconSY); m_selectedHeight = m_normalHeight + 4 + 2 * m_textHeight; - SendDlgItemMessage(m_hwnd, IDC_NAME, WM_SETFONT, (WPARAM)m_hfntTitle, 0); + m_name.SendMsg(WM_SETFONT, (WPARAM)m_hfntTitle, 0); SendDlgItemMessage(m_hwnd, IDC_TXT_ACCOUNT, WM_SETFONT, (WPARAM)m_hfntTitle, 0); SendDlgItemMessage(m_hwnd, IDC_TXT_ADDITIONAL, WM_SETFONT, (WPARAM)m_hfntTitle, 0); @@ -671,15 +675,6 @@ public: virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override { switch (msg) { - case WM_CTLCOLORSTATIC: - switch (GetDlgCtrlID((HWND)lParam)) { - case IDC_WHITERECT: - case IDC_NAME: - SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); - return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); - } - break; - case WM_MY_REFRESH: m_iSelected = -1; { diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp index f71905f386..960393eba9 100644 --- a/src/mir_core/src/ui_utils.cpp +++ b/src/mir_core/src/ui_utils.cpp @@ -122,6 +122,16 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) m_initialized = true; return TRUE; + case WM_CTLCOLOREDIT: + case WM_CTLCOLORSTATIC: + if (CCtrlBase *ctrl = FindControl(HWND(lParam))) { + if (ctrl->m_bUseSystemColors) { + SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); + return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); + } + } + break; + case WM_MEASUREITEM: { MEASUREITEMSTRUCT *param = (MEASUREITEMSTRUCT *)lParam; -- cgit v1.2.3