Index: colordlg.c =================================================================== --- colordlg.c (revision 72030) +++ colordlg.c (working copy) @@ -320,18 +320,19 @@ HUE */ /*********************************************************************** - * CC_MouseCheckColorGraph [internal] + * CC_GetMouseHitPos [internal] */ -static BOOL CC_MouseCheckColorGraph( HWND hDlg, int dlgitem, int *hori, int *vert, LPARAM lParam ) +static BOOL CC_GetMouseHitPos(CCPRIV *infoPtr, int dlgitem, int *hori, int *vert, LPARAM lParam) { HWND hwnd; POINT point; RECT rect; long x,y; + HWND hDlg = infoPtr->hwndSelf; CONV_LPARAMTOPOINT(lParam, &point); ClientToScreen(hDlg, &point); - hwnd = GetDlgItem( hDlg, dlgitem ); + hwnd = GetDlgItem(hDlg, dlgitem); GetWindowRect(hwnd, &rect); if (!PtInRect(&rect, point)) @@ -1094,6 +1095,7 @@ infoPtr->capturedGraph = 0; ReleaseCapture(); CC_PaintCross(infoPtr); + ClipCursor(NULL); return 1; } return 0; @@ -1112,7 +1114,7 @@ ptrh = &infoPtr->h; ptrs = &infoPtr->s; } - if (CC_MouseCheckColorGraph( infoPtr->hwndSelf, infoPtr->capturedGraph, ptrh, ptrs, lParam)) + if (CC_GetMouseHitPos(infoPtr, infoPtr->capturedGraph, ptrh, ptrs, lParam)) { infoPtr->lpcc->rgbResult = CC_HSLtoRGB(infoPtr->h, infoPtr->s, infoPtr->l); CC_EditSetRGB(infoPtr); @@ -1132,6 +1134,19 @@ } /*********************************************************************** + * CC_ClipCursor [internal] + */ +static void CC_ClipCursor(HWND hDlg, int nCtrlID) +{ + RECT rc; + HWND hCtrl; + + hCtrl = GetDlgItem(hDlg, nCtrlID); + GetWindowRect(hCtrl, &rc); + ClipCursor(&rc); +} + +/*********************************************************************** * CC_WMLButtonDown [internal] */ static LRESULT CC_WMLButtonDown( CCPRIV *infoPtr, LPARAM lParam ) @@ -1138,27 +1153,27 @@ { int i = 0; - if (CC_MouseCheckPredefColorArray(infoPtr, 6, 8, lParam)) + if (CC_MouseCheckPredefColorArray(infoPtr, 6, 8, lParam) || + CC_MouseCheckUserColorArray(infoPtr, 2, 8, lParam)) + { i = 1; - else - if (CC_MouseCheckUserColorArray(infoPtr, 2, 8, lParam)) - i = 1; - else - if (CC_MouseCheckColorGraph(infoPtr->hwndSelf, IDC_COLOR_GRAPH, &infoPtr->h, &infoPtr->s, lParam)) - { - i = 2; - infoPtr->capturedGraph = IDC_COLOR_GRAPH; - } - else - if (CC_MouseCheckColorGraph(infoPtr->hwndSelf, IDC_COLOR_LUMBAR, NULL, &infoPtr->l, lParam)) - { - i = 2; - infoPtr->capturedGraph = IDC_COLOR_LUMBAR; - } + } + else if (CC_GetMouseHitPos(infoPtr, IDC_COLOR_GRAPH, &infoPtr->h, &infoPtr->s, lParam)) + { + i = 2; + infoPtr->capturedGraph = IDC_COLOR_GRAPH; + } + else if (CC_GetMouseHitPos(infoPtr, IDC_COLOR_LUMBAR, NULL, &infoPtr->l, lParam)) + { + i = 2; + infoPtr->capturedGraph = IDC_COLOR_LUMBAR; + } + if ( i == 2 ) { SetCapture(infoPtr->hwndSelf); infoPtr->lpcc->rgbResult = CC_HSLtoRGB(infoPtr->h, infoPtr->s, infoPtr->l); + CC_ClipCursor(infoPtr->hwndSelf, infoPtr->capturedGraph); } if ( i == 1 ) { @@ -1231,16 +1246,23 @@ if (CC_WMMouseMove(lpp, lParam)) return TRUE; break; - case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/ - if (CC_WMLButtonUp(lpp)) - return TRUE; + case WM_LBUTTONUP: + if (CC_WMLButtonUp(lpp)) + return TRUE; break; - case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/ - if (CC_WMLButtonDown(lpp, lParam)) - return TRUE; - break; + case WM_LBUTTONDOWN: + if (CC_WMLButtonDown(lpp, lParam)) + return TRUE; + break; + case WM_CAPTURECHANGED: + ClipCursor(NULL); + break; + case WM_ACTIVATE: + if (LOWORD(wParam) == WA_INACTIVE) + ClipCursor(NULL); + break; } - return FALSE ; + return FALSE; } /***********************************************************************