From 8e10b13b38995be8e810342d21040a4324cbfeef Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 15 Jul 2013 11:10:19 +0000 Subject: nasty clutch with the custom window proc replaced with the standard mir_subclassWindow git-svn-id: http://svn.miranda-ng.org/main/trunk@5359 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/src/modern_toolbar.cpp | 24 ++++++++---------------- plugins/Clist_nicer/src/CLCButton.cpp | 6 ++---- plugins/ExternalAPI/m_toptoolbar.h | 13 ++----------- plugins/TopToolBar/TopToolBar_10.vcxproj | 1 + plugins/TopToolBar/TopToolBar_10.vcxproj.filters | 3 +++ plugins/TopToolBar/TopToolBar_11.vcxproj | 1 + plugins/TopToolBar/TopToolBar_11.vcxproj.filters | 3 +++ plugins/TopToolBar/src/toolbarwnd.cpp | 21 +++++---------------- 8 files changed, 25 insertions(+), 47 deletions(-) (limited to 'plugins') diff --git a/plugins/Clist_modern/src/modern_toolbar.cpp b/plugins/Clist_modern/src/modern_toolbar.cpp index a2624b8f17..d3156fd08c 100644 --- a/plugins/Clist_modern/src/modern_toolbar.cpp +++ b/plugins/Clist_modern/src/modern_toolbar.cpp @@ -216,8 +216,7 @@ static LRESULT CALLBACK toolbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA switch( msg ) { case WM_ERASEBKGND: - pMTBInfo->lResult = (g_CluiData.fDisableSkinEngine) ? sttDrawToolBarBackground(hwnd, (HDC)wParam, NULL, pMTBInfo) : 0; - return 1; + return (g_CluiData.fDisableSkinEngine) ? sttDrawToolBarBackground(hwnd, (HDC)wParam, NULL, pMTBInfo) : 0; case WM_NCPAINT: case WM_PAINT: @@ -233,15 +232,12 @@ static LRESULT CALLBACK toolbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA EndPaint(hwnd,&ps); } } - - pMTBInfo->lResult = DefWindowProc(hwnd, msg, wParam, lParam); - return 1; + return DefWindowProc(hwnd, msg, wParam, lParam); case WM_NOTIFY: if (((LPNMHDR) lParam)->code == BUTTONNEEDREDRAW) pcli->pfnInvalidateRect(hwnd, NULL, FALSE); - pMTBInfo->lResult = 0; - return 1; + return 0; case MTBM_LAYEREDPAINT: { @@ -263,19 +259,15 @@ static LRESULT CALLBACK toolbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA SendMessage(mtbi->hWindow, BUTTONDRAWINPARENT, (WPARAM)hDC, (LPARAM)&Offset); } } - pMTBInfo->lResult = 0; - return 1; + return 0; case WM_DESTROY: xpt_FreeThemeForWindow(hwnd); CallService(MS_SKINENG_REGISTERPAINTSUB, (WPARAM)hwnd, 0); - - default: - return 0; + break; } - pMTBInfo->lResult = TRUE; - return 1; + return mir_callNextSubclass(hwnd, toolbarWndProc, msg, wParam, lParam); } static int ToolBar_LayeredPaintProc(HWND hWnd, HDC hDC, RECT *rcPaint, HRGN rgn, DWORD dFlags, void * CallBackData) @@ -285,8 +277,8 @@ static int ToolBar_LayeredPaintProc(HWND hWnd, HDC hDC, RECT *rcPaint, HRGN rgn, void CustomizeToolbar(HWND hwnd) { - TTBCtrlCustomize custData = { sizeof(ModernToolbarCtrl), toolbarWndProc }; - SendMessage(hwnd, TTB_SETCUSTOM, 0, (LPARAM)&custData); + mir_subclassWindow(hwnd, toolbarWndProc); + SendMessage(hwnd, TTB_SETCUSTOMDATASIZE, 0, sizeof(ModernToolbarCtrl)); ModernToolbarCtrl* pMTBInfo = (ModernToolbarCtrl*)GetWindowLongPtr(hwnd, 0); diff --git a/plugins/Clist_nicer/src/CLCButton.cpp b/plugins/Clist_nicer/src/CLCButton.cpp index b5c51182d6..01a0b6281d 100644 --- a/plugins/Clist_nicer/src/CLCButton.cpp +++ b/plugins/Clist_nicer/src/CLCButton.cpp @@ -510,16 +510,14 @@ static LRESULT CALLBACK ToolbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA if (msg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED) SendMessage(pcli->hwndContactList, msg, wParam, lParam); - return 0; + return mir_callNextSubclass(hwnd, ToolbarWndProc, msg, wParam, lParam); } static void CustomizeToolbar(HANDLE hButton, HWND hWnd, LPARAM) { // we don't customize the toolbar window, only buttons if (hButton == TTB_WINDOW_HANDLE) { - TTBCtrlCustomize custData = { sizeof(TTBCtrl), ToolbarWndProc }; - SendMessage(hWnd, TTB_SETCUSTOM, 0, (LPARAM)&custData); - + mir_subclassWindow(hWnd, ToolbarWndProc); InitDefaultButtons(); return; } diff --git a/plugins/ExternalAPI/m_toptoolbar.h b/plugins/ExternalAPI/m_toptoolbar.h index 4b037a3168..fc4399f5f7 100644 --- a/plugins/ExternalAPI/m_toptoolbar.h +++ b/plugins/ExternalAPI/m_toptoolbar.h @@ -161,22 +161,13 @@ struct TTBCtrl BOOL bHardUpdate; // clist modern requires to delete buttons to update them SortedList* pButtonList; - - LRESULT lResult; // custom window proc result - WNDPROC fnWindowProc; // custom window proc -}; - -struct TTBCtrlCustomize -{ - size_t cbLen; // total length of the internal data structure - WNDPROC fnWindowProc; // subclassed windows procedure for the custom button }; // Sets the custom painting procedure for a toolbar // wParam = not used -// lParam = TTBCtrlCustomize* +// lParam = size_t: size of new data block (published from TTBCtrl) // Usage: SendMessage(hwndToolbar, TTB_SETCUSTOM, 0, (LPARAM)&CustomData); // Only works on TopToolbars -#define TTB_SETCUSTOM (WM_USER+1) +#define TTB_SETCUSTOMDATASIZE (WM_USER+1) #endif diff --git a/plugins/TopToolBar/TopToolBar_10.vcxproj b/plugins/TopToolBar/TopToolBar_10.vcxproj index c204b45828..2c863dc385 100644 --- a/plugins/TopToolBar/TopToolBar_10.vcxproj +++ b/plugins/TopToolBar/TopToolBar_10.vcxproj @@ -188,6 +188,7 @@ + diff --git a/plugins/TopToolBar/TopToolBar_10.vcxproj.filters b/plugins/TopToolBar/TopToolBar_10.vcxproj.filters index bbb0f350ff..0e75aeb8e7 100644 --- a/plugins/TopToolBar/TopToolBar_10.vcxproj.filters +++ b/plugins/TopToolBar/TopToolBar_10.vcxproj.filters @@ -27,6 +27,9 @@ Header Files + + Header Files + diff --git a/plugins/TopToolBar/TopToolBar_11.vcxproj b/plugins/TopToolBar/TopToolBar_11.vcxproj index a70a3b8a41..86ca8e26f3 100644 --- a/plugins/TopToolBar/TopToolBar_11.vcxproj +++ b/plugins/TopToolBar/TopToolBar_11.vcxproj @@ -191,6 +191,7 @@ + diff --git a/plugins/TopToolBar/TopToolBar_11.vcxproj.filters b/plugins/TopToolBar/TopToolBar_11.vcxproj.filters index bbb0f350ff..0e75aeb8e7 100644 --- a/plugins/TopToolBar/TopToolBar_11.vcxproj.filters +++ b/plugins/TopToolBar/TopToolBar_11.vcxproj.filters @@ -27,6 +27,9 @@ Header Files + + Header Files + diff --git a/plugins/TopToolBar/src/toolbarwnd.cpp b/plugins/TopToolBar/src/toolbarwnd.cpp index b0778edff9..082ea3a590 100644 --- a/plugins/TopToolBar/src/toolbarwnd.cpp +++ b/plugins/TopToolBar/src/toolbarwnd.cpp @@ -117,10 +117,6 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara { static bool supressRepos = false; - if (g_ctrl->fnWindowProc != NULL) - if ( g_ctrl->fnWindowProc(hwnd, msg, wParam, lParam)) - return g_ctrl->lResult; - switch(msg) { case WM_CREATE: g_ctrl->hWnd = hwnd; @@ -227,19 +223,12 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } break; - case TTB_SETCUSTOM: - { - TTBCtrlCustomize *pCustom = (TTBCtrlCustomize*)lParam; - if (pCustom == NULL || g_ctrl->fnWindowProc) - break; - - g_ctrl = (TTBCtrl*)mir_realloc(g_ctrl, pCustom->cbLen); - if (pCustom->cbLen > sizeof(TTBCtrl)) - memset(g_ctrl+1, 0, pCustom->cbLen - sizeof(TTBCtrl)); + case TTB_SETCUSTOMDATASIZE: + g_ctrl = (TTBCtrl*)mir_realloc(g_ctrl, lParam); + if (lParam > sizeof(TTBCtrl)) + memset(g_ctrl+1, 0, lParam - sizeof(TTBCtrl)); - g_ctrl->fnWindowProc = pCustom->fnWindowProc; - SetWindowLongPtr(hwnd, 0, (LONG_PTR)g_ctrl); - } + SetWindowLongPtr(hwnd, 0, (LONG_PTR)g_ctrl); break; default: -- cgit v1.2.3