comctl32/button: Invalidate on BM_SETSTATE.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2018-02-11 19:19:54 +03:00 committed by Alexandre Julliard
parent f1cc2da207
commit f8eb74e10c
2 changed files with 18 additions and 14 deletions

View file

@ -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;
paint_button( hWnd, btn_type, ODA_SELECT );
if ((state ^ new_state) & BST_PUSHED)
{
if (wParam)
state |= BST_PUSHED;
else
state &= ~BST_PUSHED;
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;
}
}

View file

@ -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);