From 2c60bdb440a4c67591e4d3e2584881da0f4bd74a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 9 Nov 2023 20:39:16 +0300 Subject: unused window subclassing removed --- src/core/stdmsg/src/stdafx.h | 11 ++++++++++- src/core/stdmsg/src/tabs.cpp | 43 ++++++++++++++++++++----------------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 40b2e4b02b..5f2f400c7f 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -74,6 +74,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. class CMsgDialog; +struct CCtrlMsgPages : public CCtrlPages +{ + CCtrlMsgPages(CDlgBase *dlg, int ctrlId) : + CCtrlPages(dlg, ctrlId) + {} + + LRESULT CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam) override; +}; + class CTabbedWindow : public CDlgBase { void SetWindowPosition(); @@ -85,7 +94,7 @@ class CTabbedWindow : public CDlgBase int m_statusHeight = 0; public: - CCtrlPages m_tab; + CCtrlMsgPages m_tab; HWND m_hwndStatus = nullptr; CMsgDialog *m_pEmbed = nullptr; diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index 668050a8a2..c17bebbf4c 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -41,10 +41,10 @@ CTabbedWindow* GetContainer() ///////////////////////////////////////////////////////////////////////////////////////// -static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +LRESULT CCtrlMsgPages::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam) { - CTabbedWindow *pOwner = (CTabbedWindow*)GetWindowLongPtr(hwnd, GWLP_USERDATA); TCHITTESTINFO tci = {}; + CTabbedWindow *pOwner = (CTabbedWindow *)m_parentWnd; static bool bDragging = false; static int iBeginIndex = 0; @@ -52,18 +52,18 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR case WM_LBUTTONDOWN: tci.pt.x = (short)LOWORD(GetMessagePos()); tci.pt.y = (short)HIWORD(GetMessagePos()); - if (DragDetect(hwnd, tci.pt) && TabCtrl_GetItemCount(hwnd) > 1) { + if (DragDetect(m_hwnd, tci.pt) && TabCtrl_GetItemCount(m_hwnd) > 1) { tci.flags = TCHT_ONITEM; - ScreenToClient(hwnd, &tci.pt); - int idx = TabCtrl_HitTest(hwnd, &tci); + ScreenToClient(m_hwnd, &tci.pt); + int idx = TabCtrl_HitTest(m_hwnd, &tci); if (idx != -1) { - CMsgDialog *pDlg = (CMsgDialog*)pOwner->m_tab.GetNthPage(idx); + CMsgDialog *pDlg = (CMsgDialog *)GetNthPage(idx); if (pDlg) { bDragging = true; iBeginIndex = idx; ImageList_BeginDrag(Clist_GetImageList(), pDlg->GetImageId(), 8, 8); - ImageList_DragEnter(hwnd, tci.pt.x, tci.pt.y); - SetCapture(hwnd); + ImageList_DragEnter(m_hwnd, tci.pt.x, tci.pt.y); + SetCapture(m_hwnd); } return TRUE; } @@ -73,7 +73,7 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR case WM_CAPTURECHANGED: bDragging = false; - ImageList_DragLeave(hwnd); + ImageList_DragLeave(m_hwnd); ImageList_EndDrag(); break; @@ -81,7 +81,7 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR if (bDragging) { tci.pt.x = (short)LOWORD(GetMessagePos()); tci.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(hwnd, &tci.pt); + ScreenToClient(m_hwnd, &tci.pt); ImageList_DragMove(tci.pt.x, tci.pt.y); } break; @@ -92,11 +92,11 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR tci.pt.y = (short)HIWORD(GetMessagePos()); tci.flags = TCHT_ONITEM; bDragging = false; - ImageList_DragLeave(hwnd); + ImageList_DragLeave(m_hwnd); ImageList_EndDrag(); - ScreenToClient(hwnd, &tci.pt); - int idx = TabCtrl_HitTest(hwnd, &tci); + ScreenToClient(m_hwnd, &tci.pt); + int idx = TabCtrl_HitTest(m_hwnd, &tci); if (idx != -1 && idx != iBeginIndex) pOwner->DropTab(idx, iBeginIndex); } @@ -106,12 +106,12 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR if (g_Settings.bTabCloseOnDblClick) { tci.pt.x = (short)LOWORD(GetMessagePos()); tci.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(hwnd, &tci.pt); + ScreenToClient(m_hwnd, &tci.pt); tci.flags = TCHT_ONITEM; - int idx = TabCtrl_HitTest(hwnd, &tci); + int idx = TabCtrl_HitTest(m_hwnd, &tci); if (idx != -1) { - CMsgDialog *pDlg = (CMsgDialog*)pOwner->m_tab.GetNthPage(idx); + CMsgDialog *pDlg = (CMsgDialog *)GetNthPage(idx); if (pDlg) pDlg->CloseTab(); } @@ -123,17 +123,17 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR tci.pt.y = (short)HIWORD(GetMessagePos()); tci.flags = TCHT_ONITEM; - ScreenToClient(hwnd, &tci.pt); - int idx = TabCtrl_HitTest(hwnd, &tci); + ScreenToClient(m_hwnd, &tci.pt); + int idx = TabCtrl_HitTest(m_hwnd, &tci); if (idx != -1) { - CMsgDialog *pDlg = (CMsgDialog*)pOwner->m_tab.GetNthPage(idx); + CMsgDialog *pDlg = (CMsgDialog *)GetNthPage(idx); if (pDlg) pDlg->CloseTab(); } break; } - return mir_callNextSubclass(hwnd, TabSubclassProc, msg, wParam, lParam); + return CCtrlPages::CustomWndProc(msg, wParam, lParam); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -147,9 +147,6 @@ CTabbedWindow::CTabbedWindow() : bool CTabbedWindow::OnInitDialog() { - SetWindowLongPtr(m_tab.GetHwnd(), GWLP_USERDATA, LPARAM(this)); - mir_subclassWindow(m_tab.GetHwnd(), ::TabSubclassProc); - m_hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, nullptr, WS_CHILD | WS_VISIBLE | SBT_TOOLTIPS | SBARS_SIZEGRIP, 0, 0, 0, 0, m_hwnd, nullptr, g_plugin.getInst(), nullptr); SendMessage(m_hwndStatus, SB_SETMINHEIGHT, GetSystemMetrics(SM_CYSMICON), 0); -- cgit v1.2.3