[edit:]
As you can see from that exerpt from my switch ( msg ) thingy I capture the mouse when it's down and release it when it's up, this way if you click and drag outside of my control (which is a button) it will still reset it's down status to false.Code:case WM_LBUTTONDBLCLK: { cCLRBTN *clrbtn = (cCLRBTN*)GetWindowLong ( hwnd, GWL_USERDATA ); clrbtn->down = true; InvalidateRect ( hwnd, NULL, TRUE ); UpdateWindow ( hwnd ); clrbtn->down = false; InvalidateRect ( hwnd, NULL, TRUE ); UpdateWindow ( hwnd ); SendMessage ( GetParent ( hwnd ), WM_COMMAND, (WPARAM)MAKEWPARAM((int)GetWindowLong ( hwnd, GWL_ID ),0 ), (LPARAM)hwnd ); } case WM_LBUTTONDOWN: { SetCapture ( hwnd ); cCLRBTN *clrbtn = (cCLRBTN*)GetWindowLong ( hwnd, GWL_USERDATA ); clrbtn->down = true; InvalidateRect ( hwnd, NULL, TRUE ); UpdateWindow ( hwnd ); return 0; } case WM_LBUTTONUP: { cCLRBTN *clrbtn = (cCLRBTN*)GetWindowLong ( hwnd, GWL_USERDATA ); if ( clrbtn->down ) { clrbtn->down = false; InvalidateRect ( hwnd, NULL, TRUE ); UpdateWindow ( hwnd ); SendMessage ( GetParent ( hwnd ), WM_COMMAND, (WPARAM)MAKEWPARAM((int)GetWindowLong ( hwnd, GWL_ID ),0 ), (LPARAM)hwnd ); } ReleaseCapture ( ); return 0; }
However I'd rather that if you moved outside the control it popped up and it's down status was returned to false, just like other buttons.. This way you can drag outside of it and let go and you won't execute it's action.



LinkBack URL
About LinkBacks



CornedBee
both of your posts are very helpful indeed..