[PATCH 2/4] comctl32/button: Invalidate on BM_SETSTATE

Nikolay Sivov nsivov at codeweavers.com
Sun Feb 11 10:19:54 CST 2018


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/comctl32/button.c       | 22 +++++++++++++++-------
 dlls/comctl32/tests/button.c | 10 +++-------
 2 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c
index c8f85d981e..85aa47f4bb 100644
--- a/dlls/comctl32/button.c
+++ b/dlls/comctl32/button.c
@@ -305,7 +305,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
     POINT pt;
     LONG style = GetWindowLongW( hWnd, GWL_STYLE );
     UINT btn_type = get_button_type( style );
-    LONG state;
+    LONG state, new_state;
     HANDLE oldHbitmap;
     HTHEME theme;
 
@@ -674,12 +674,21 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
 
     case BM_SETSTATE:
         state = get_button_state( hWnd );
-        if (wParam)
-            set_button_state( hWnd, state | BST_PUSHED );
-        else
-            set_button_state( hWnd, state & ~BST_PUSHED );
+        new_state = wParam ? BST_PUSHED : 0;
+
+        if ((state ^ new_state) & BST_PUSHED)
+        {
+            if (wParam)
+                state |= BST_PUSHED;
+            else
+                state &= ~BST_PUSHED;
 
-        paint_button( hWnd, btn_type, ODA_SELECT );
+            if (btn_type == BS_USERBUTTON)
+                BUTTON_NOTIFY_PARENT( hWnd, (state & BST_PUSHED) ? BN_HILITE : BN_UNHILITE );
+            set_button_state( hWnd, state );
+
+            InvalidateRect( hWnd, NULL, FALSE );
+        }
         break;
 
     case WM_NCHITTEST:
@@ -1206,7 +1215,6 @@ static void UB_Paint( HWND hwnd, HDC hDC, UINT action )
         break;
 
     default:
-        BUTTON_NOTIFY_PARENT( hwnd, BN_PAINT );
         break;
     }
 }
diff --git a/dlls/comctl32/tests/button.c b/dlls/comctl32/tests/button.c
index 425e1455ff..38446aab67 100644
--- a/dlls/comctl32/tests/button.c
+++ b/dlls/comctl32/tests/button.c
@@ -350,8 +350,6 @@ static const struct message setstate_seq[] =
     { BM_SETSTATE, sent },
     { WM_APP, sent|wparam|lparam, 0, 0 },
     { WM_PAINT, sent },
-    { WM_NCPAINT, sent|optional }, /* FIXME: Wine sends it */
-    { WM_ERASEBKGND, sent|defwinproc|optional },
     { WM_PAINT, sent|optional },
     { 0 }
 };
@@ -372,8 +370,6 @@ static const struct message setstate_user_seq[] =
     { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_HILITE) },
     { WM_APP, sent|wparam|lparam, 0, 0 },
     { WM_PAINT, sent },
-    { WM_NCPAINT, sent|optional }, /* FIXME: Wine sends it */
-    { WM_ERASEBKGND, sent|defwinproc|optional },
     { 0 }
 };
 
@@ -596,7 +592,7 @@ static void test_button_messages(void)
         SendMessageA(hwnd, BM_SETSTYLE, button[i].style | BS_BOTTOM, TRUE);
         SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */
         while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
-        todo = button[i].style == BS_USERBUTTON || button[i].style == BS_OWNERDRAW;
+        todo = button[i].style == BS_OWNERDRAW;
         ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].setstyle, "BM_SETSTYLE on a button", todo);
 
         style = GetWindowLongA(hwnd, GWL_STYLE);
@@ -612,7 +608,7 @@ static void test_button_messages(void)
         SendMessageA(hwnd, BM_SETSTATE, TRUE, 0);
         SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */
         while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
-        ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].setstate, "BM_SETSTATE/TRUE on a button", TRUE);
+        ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].setstate, "BM_SETSTATE/TRUE on a button", FALSE);
 
         state = SendMessageA(hwnd, BM_GETSTATE, 0, 0);
         ok(state == BST_PUSHED, "expected state 0x0004, got %04x\n", state);
@@ -626,7 +622,7 @@ static void test_button_messages(void)
         SendMessageA(hwnd, BM_SETSTATE, FALSE, 0);
         SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */
         while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
-        ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].clearstate, "BM_SETSTATE/FALSE on a button", TRUE);
+        ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].clearstate, "BM_SETSTATE/FALSE on a button", FALSE);
 
         state = SendMessageA(hwnd, BM_GETSTATE, 0, 0);
         ok(state == 0, "expected state 0, got %04x\n", state);
-- 
2.15.1




More information about the wine-devel mailing list