[User32]
[reactos.git] / reactos / win32ss / user / user32 / controls / button.c
index f4c5959..8b9a9f4 100644 (file)
@@ -356,16 +356,18 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
 
     case WM_PRINTCLIENT:
     case WM_PAINT:
+    {
+        PAINTSTRUCT ps;
+        HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps );
         if (btnPaintFunc[btn_type])
         {
-            PAINTSTRUCT ps;
-            HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps );
             int nOldMode = SetBkMode( hdc, OPAQUE );
             (btnPaintFunc[btn_type])( hWnd, hdc, ODA_DRAWENTIRE );
             SetBkMode(hdc, nOldMode); /*  reset painting mode */
-            if( !wParam ) EndPaint( hWnd, &ps );
         }
+        if ( !wParam ) EndPaint( hWnd, &ps );
         break;
+    }
 
     case WM_KEYDOWN:
        if (wParam == VK_SPACE)
@@ -398,6 +400,8 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
            break;
        /* fall through */
     case WM_LBUTTONUP:
+    {
+        BOOL TellParent = FALSE; //// ReactOS see note below.
         state = get_button_state( hWnd );
         if (!(state & BUTTON_BTNPRESSED)) break;
         state &= BUTTON_NSTATES;
@@ -425,9 +429,11 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
                                 (state & BST_INDETERMINATE) ? 0 : ((state & 3) + 1), 0 );
                 break;
             }
-            BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED);
+            TellParent = TRUE; // <---- Fix CORE-10194, Notify parent after capture is released.
         }
         ReleaseCapture();
+        if (TellParent) BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED);
+    }
         break;
 
     case WM_CAPTURECHANGED:
@@ -541,7 +547,6 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
         break;
 
     case BM_SETSTYLE:
-        if ((wParam & BS_TYPEMASK) >= MAX_BTN_TYPE) break;
         btn_type = wParam & BS_TYPEMASK;
         style = (style & ~BS_TYPEMASK) | btn_type;
 #ifdef __REACTOS__