From a6ad2609bad6a7c4b6f30c17973af9dcaba8c8af Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 9 Jul 2012 13:47:44 +0000 Subject: slightly changed design of custom MButtonCtrl window procedure. Clist Nicer works ok git-svn-id: http://svn.miranda-ng.org/main/trunk@880 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_button_int.h | 1 + plugins/Clist_modern/modern_tbbutton.cpp | 7 ++++--- plugins/Clist_modern/modern_toolbar.cpp | 15 ++++++++++++++- plugins/Clist_nicer/SRC/CLCButton.cpp | 30 ++++++++++++++++++------------ src/modules/button/button.cpp | 8 +++----- 5 files changed, 40 insertions(+), 21 deletions(-) diff --git a/include/m_button_int.h b/include/m_button_int.h index 684449c7eb..08004b5cb6 100644 --- a/include/m_button_int.h +++ b/include/m_button_int.h @@ -51,6 +51,7 @@ struct MButtonCtrl bIsThemed, // themed button bIsSkinned; // skinned button + LRESULT lResult; // custom window proc result WNDPROC fnWindowProc; // custom window proc pfnPainterFunc fnPainter; // custom button painter diff --git a/plugins/Clist_modern/modern_tbbutton.cpp b/plugins/Clist_modern/modern_tbbutton.cpp index dadf53637a..d9d95e7969 100644 --- a/plugins/Clist_modern/modern_tbbutton.cpp +++ b/plugins/Clist_modern/modern_tbbutton.cpp @@ -267,17 +267,17 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam RECT nillRect = {0}; lpSBData->rcMargins = nillRect; } - return 0; + break; case BUTTONSETID: lstrcpynA(lpSBData->szButtonID, (char *)lParam, SIZEOF(lpSBData->szButtonID)-1); lpSBData->szButtonID[SIZEOF(lpSBData->szButtonID)-1] = '\0'; - return 0; + break; case BUTTONDRAWINPARENT: if (IsWindowVisible(hwndDlg)) PaintWorker(lpSBData, (HDC) wParam, (POINT*) lParam); - return 0; + break; case WM_NCPAINT: case WM_PAINT: @@ -290,6 +290,7 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam } } ValidateRect(hwndDlg,NULL); + lpSBData->lResult = 0; return 1; case WM_CAPTURECHANGED: diff --git a/plugins/Clist_modern/modern_toolbar.cpp b/plugins/Clist_modern/modern_toolbar.cpp index 606dc1122a..89de2e2609 100644 --- a/plugins/Clist_modern/modern_toolbar.cpp +++ b/plugins/Clist_modern/modern_toolbar.cpp @@ -35,6 +35,7 @@ struct char *pszTooltipUp, *pszTooltipDn; int icoDefIdx, defResource, defResource2; BOOL bVisByDefault; + HANDLE hButton; } static BTNS[] = { @@ -74,8 +75,13 @@ static int Modern_InitButtons(WPARAM, LPARAM) else tbb.dwFlags |= TTBBF_ISSEPARATOR; tbb.dwFlags |= (BTNS[i].bVisByDefault ? TTBBF_VISIBLE :0 ); - TopToolbar_AddButton(&tbb); + BTNS[i].hButton = TopToolbar_AddButton(&tbb); } + + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[3].hButton, db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT) ? TTBST_PUSHED : TTBST_RELEASED); + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[6].hButton, db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT) ? TTBST_PUSHED : TTBST_RELEASED); + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[7].hButton, db_get_b(NULL, "Skin", "UseSound", SETTING_ENABLESOUNDS_DEFAULT) ? TTBST_PUSHED : TTBST_RELEASED); + return 1; } @@ -241,11 +247,18 @@ static LRESULT CALLBACK toolbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA return 0; } +static int ToolBar_LayeredPaintProc(HWND hWnd, HDC hDC, RECT *rcPaint, HRGN rgn, DWORD dFlags, void * CallBackData) +{ + return SendMessage(hWnd, MTBM_LAYEREDPAINT,(WPARAM)hDC,0); +} + void CustomizeToolbar(HWND hwnd) { TTBCtrlCustomize custData = { sizeof(ModernToolbarCtrl), toolbarWndProc, NULL }; SendMessage(hwnd, TTB_SETCUSTOM, 0, (LPARAM)&custData); + CallService(MS_SKINENG_REGISTERPAINTSUB,(WPARAM)hwnd,(LPARAM)ToolBar_LayeredPaintProc); + ModernToolbarCtrl* pMTBInfo = (ModernToolbarCtrl*)GetWindowLongPtr(hwnd, 0); pMTBInfo->nLineCount = 1; pMTBInfo->mtbXPTheme = xpt_AddThemeHandle(hwnd, L"TOOLBAR"); diff --git a/plugins/Clist_nicer/SRC/CLCButton.cpp b/plugins/Clist_nicer/SRC/CLCButton.cpp index 3ab8587d0f..2fb254b140 100644 --- a/plugins/Clist_nicer/SRC/CLCButton.cpp +++ b/plugins/Clist_nicer/SRC/CLCButton.cpp @@ -47,12 +47,15 @@ static BTNS[] = { IDC_TBCLEARVIEWMODE, "CLN_CLVM_reset", NULL, LPGEN("Clear view mode"), 1, 0, 0 } }; +static int g_index = -1; + static int InitDefaultButtons(WPARAM, LPARAM) { TTBButton tbb = { 0 }; tbb.cbSize = sizeof(tbb); for (int i=0; i < SIZEOF(BTNS); i++ ) { + g_index = i; tbb.dwFlags = TTBBF_ICONBYHANDLE; if (BTNS[i].pszButtonID) { tbb.pszTooltipUp = tbb.pszTooltipDn = tbb.name = BTNS[i].pszButtonName; @@ -63,9 +66,10 @@ static int InitDefaultButtons(WPARAM, LPARAM) } else tbb.dwFlags |= TTBBF_ISSEPARATOR; - tbb.dwFlags |= (BTNS[i].isVis ? TTBBF_VISIBLE :0 ); + tbb.dwFlags |= (BTNS[i].isVis ? TTBBF_VISIBLE : 0 ); BTNS[i].hButton = TopToolbar_AddButton(&tbb); } + g_index = -1; return 1; } @@ -338,13 +342,16 @@ static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == tolower((int) wParam)) { if (!bct->bSendOnDown) SendMessage(pcli->hwndContactList, WM_COMMAND, MAKELONG(bct->iCtrlID, BN_CLICKED), (LPARAM) hwndDlg); - return 0; + bct->lResult = 0; + return 1; } break; case BM_GETIMAGE: - if (wParam == IMAGE_ICON) - return (LRESULT)(bct->hIconPrivate ? bct->hIconPrivate : bct->hIcon); + if (wParam == IMAGE_ICON) { + bct->lResult = (LRESULT)(bct->hIconPrivate ? bct->hIconPrivate : bct->hIcon); + return 1; + } break; case BM_SETIMAGE: @@ -420,6 +427,7 @@ static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L SendMessage(pcli->hwndContactList, WM_COMMAND, MAKELONG(bct->iCtrlID, BN_CLICKED), (LPARAM) hwndDlg); bct->stateId = PBS_NORMAL; InvalidateRect(bct->hwnd, NULL, TRUE); + bct->lResult = 0; return 1; } } @@ -434,7 +442,8 @@ static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L switch( SendMessage(pcli->hwndContactList, WM_NCHITTEST, wParam, lParam)) { case HTLEFT: case HTRIGHT: case HTBOTTOM: case HTTOP: case HTTOPLEFT: case HTTOPRIGHT: case HTBOTTOMLEFT: case HTBOTTOMRIGHT: - return HTTRANSPARENT; + bct->lResult = HTTRANSPARENT; + return 1; } } return 0; @@ -456,17 +465,14 @@ static void CustomizeToolbar(HANDLE hButton, HWND hWnd, LPARAM) return; SetButtonAsCustom(hWnd); - for (int i=0; i < SIZEOF(BTNS); i++) { - if (BTNS[i].hButton != hButton) - continue; + if (g_index != -1) { // adding built-in button MButtonExtension *bct = (MButtonExtension*) GetWindowLongPtr(hWnd, 0); - bct->iCtrlID = BTNS[i].ctrlid; - if (BTNS[i].isAction) + bct->iCtrlID = BTNS[g_index].ctrlid; + if (BTNS[g_index].isAction) bct->bSendOnDown = TRUE; - if (!BTNS[i].isPush) + if (!BTNS[g_index].isPush) bct->bIsPushBtn = TRUE; - break; } } diff --git a/src/modules/button/button.cpp b/src/modules/button/button.cpp index f3384f3fcc..ed00c94f3b 100644 --- a/src/modules/button/button.cpp +++ b/src/modules/button/button.cpp @@ -261,11 +261,9 @@ static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { MButtonCtrl* bct = (MButtonCtrl *)GetWindowLongPtr(hwndDlg, 0); - if (bct && bct->fnWindowProc) { - LRESULT res = bct->fnWindowProc(hwndDlg, msg, wParam, lParam); - if (res) - return res; - } + if (bct && bct->fnWindowProc) + if ( bct->fnWindowProc(hwndDlg, msg, wParam, lParam)) + return bct->lResult; switch(msg) { case WM_NCCREATE: -- cgit v1.2.3