From a971c497d5c86f11df8a048e3e9eb88691966169 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 21 Jul 2013 10:37:30 +0000 Subject: - BUTTONSETSENDONDOWN functionality moved to the core; - custom button click processing removed from clist_nicer; - control id assignment removed and replaced with the search by HWND git-svn-id: http://svn.miranda-ng.org/main/trunk@5440 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/button/button.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/modules/button/button.cpp b/src/modules/button/button.cpp index d1b06896ea..7bbbd9ef8a 100644 --- a/src/modules/button/button.cpp +++ b/src/modules/button/button.cpp @@ -341,14 +341,14 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR break; case WM_SYSKEYUP: - if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == tolower((int)wParam)) { + if (bct->stateId != PBS_DISABLED && !bct->bSendOnDown && bct->cHot && bct->cHot == tolower((int)wParam)) { if (bct->bIsPushBtn) { if (bct->bIsPushed) { - bct->bIsPushed = 0; + bct->bIsPushed = false; bct->stateId = PBS_NORMAL; } else { - bct->bIsPushed = 1; + bct->bIsPushed = true; bct->stateId = PBS_PRESSED; } InvalidateRect(bct->hwnd, NULL, TRUE); @@ -513,6 +513,10 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR bct->fnPainter = pfnPainterFunc(lParam); break; + case BUTTONSETSENDONDOWN: + bct->bSendOnDown = (wParam != 0); + break; + case WM_SETFOCUS: // set keybord focus and redraw bct->focus = 1; InvalidateRect(bct->hwnd, NULL, TRUE); @@ -528,7 +532,7 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR break; case WM_ENABLE: // windows tells us to enable/disable - bct->stateId = wParam?PBS_NORMAL:PBS_DISABLED; + bct->stateId = wParam ? PBS_NORMAL : PBS_DISABLED; InvalidateRect(bct->hwnd, NULL, TRUE); break; @@ -543,6 +547,11 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR if (bct->stateId != PBS_DISABLED) { // don't change states if disabled bct->stateId = PBS_PRESSED; InvalidateRect(bct->hwnd, NULL, TRUE); + if (bct->bSendOnDown) { + SendMessage( GetParent(hwnd), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwnd), BN_CLICKED), (LPARAM)hwnd); + bct->stateId = PBS_NORMAL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } } break; @@ -558,8 +567,8 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR bct->stateId = (msg == WM_LBUTTONUP) ? PBS_HOT : PBS_NORMAL; InvalidateRect(bct->hwnd, NULL, TRUE); } - if (showClick) // Tell your daddy you got clicked. - SendMessage(GetParent(hwnd), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwnd), BN_CLICKED), (LPARAM)hwnd); + if (showClick && !bct->bSendOnDown) // Tell your daddy you got clicked. + SendMessage( GetParent(hwnd), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwnd), BN_CLICKED), (LPARAM)hwnd); } break; -- cgit v1.2.3