Use an extra bit in the button status byte to flag whether the
DefButtonWndProc should process the WM_LBUTTONUP message.
diff --git a/controls/button.c b/controls/button.c
index 147d82b..5ca6457 100644
--- a/controls/button.c
+++ b/controls/button.c
@@ -137,27 +137,31 @@
break;
case WM_LBUTTONDBLCLK:
- if(wndPtr->dwStyle & BS_NOTIFY ||
- style==BS_RADIOBUTTON ||
- style==BS_USERBUTTON ||
- style==BS_OWNERDRAW){
- SendMessageA( GetParent(hWnd), WM_COMMAND,
- MAKEWPARAM( wndPtr->wIDmenu, BN_DOUBLECLICKED ), hWnd);
- break;
- }
- /* fall through */
+ if(wndPtr->dwStyle & BS_NOTIFY ||
+ style==BS_RADIOBUTTON ||
+ style==BS_USERBUTTON ||
+ style==BS_OWNERDRAW) {
+ SendMessageA( GetParent(hWnd), WM_COMMAND,
+ MAKEWPARAM( wndPtr->wIDmenu, BN_DOUBLECLICKED ), hWnd);
+ break;
+ }
+ /* fall through */
case WM_LBUTTONDOWN:
SetCapture( hWnd );
SetFocus( hWnd );
SendMessageA( hWnd, BM_SETSTATE, TRUE, 0 );
+ infoPtr->state |= BUTTON_BTNPRESSED;
break;
case WM_LBUTTONUP:
- /* FIXME: real windows uses extra flags in the status for this */
- if (GetCapture() != hWnd) break;
- ReleaseCapture();
- if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
+ if (!(infoPtr->state & BUTTON_BTNPRESSED)) break;
+ infoPtr->state &= BUTTON_NSTATES;
+ if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) {
+ ReleaseCapture();
+ break;
+ }
SendMessageA( hWnd, BM_SETSTATE, FALSE, 0 );
+ ReleaseCapture();
GetClientRect( hWnd, &rect );
if (PtInRect( &rect, pt ))
{
@@ -181,6 +185,14 @@
}
break;
+ case WM_CAPTURECHANGED:
+ if (infoPtr->state & BUTTON_BTNPRESSED) {
+ infoPtr->state &= BUTTON_NSTATES;
+ if (infoPtr->state & BUTTON_HIGHLIGHTED)
+ SendMessageA( hWnd, BM_SETSTATE, FALSE, 0 );
+ }
+ break;
+
case WM_MOUSEMOVE:
if (GetCapture() == hWnd)
{
diff --git a/include/button.h b/include/button.h
index 5ccabfe..61e1555 100644
--- a/include/button.h
+++ b/include/button.h
@@ -26,6 +26,11 @@
#define BUTTON_3STATE 0x02
#define BUTTON_HIGHLIGHTED 0x04
#define BUTTON_HASFOCUS 0x08
+#define BUTTON_NSTATES 0x0F
+ /* undocumented flags */
+#define BUTTON_BTNPRESSED 0x40
+#define BUTTON_UNKNOWN2 0x20
+#define BUTTON_UNKNOWN3 0x10
#define BUTTON_STATE(hwnd) ((WIN_FindWndPtr(hwnd))->wExtra[0])