comctl32: Send parent BN_CLICKED notification when a radio button get focused.

We need to make sure here that the button is marked pressed before
it gets the focus.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56109
This commit is contained in:
Fabian Maurer 2024-11-19 02:58:12 +01:00
parent 559f2c0bf6
commit 7f59af2684
2 changed files with 13 additions and 4 deletions

View file

@ -628,15 +628,18 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
}
/* fall through */
case WM_LBUTTONDOWN:
infoPtr->state |= BUTTON_BTNPRESSED;
SetFocus( hWnd );
if ((btn_type == BS_SPLITBUTTON || btn_type == BS_DEFSPLITBUTTON) &&
!(infoPtr->split_style & BCSS_NOSPLIT) &&
notify_split_button_dropdown(infoPtr, &pt, hWnd))
{
infoPtr->state &= ~BUTTON_BTNPRESSED;
break;
}
SetCapture( hWnd );
infoPtr->state |= BUTTON_BTNPRESSED;
SendMessageW( hWnd, BM_SETSTATE, TRUE, 0 );
break;
@ -867,6 +870,12 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
if (style & BS_NOTIFY)
BUTTON_NOTIFY_PARENT(hWnd, BN_SETFOCUS);
if (((btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON)) &&
!(infoPtr->state & (BST_CHECKED | BUTTON_BTNPRESSED)))
{
BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED);
}
break;
case WM_KILLFOCUS:

View file

@ -2521,7 +2521,7 @@ static void test_radiobutton_focus(void)
flush_sequences(sequences, NUM_MSG_SEQUENCES);
SendMessageA(button, WM_SETFOCUS, 0, 0);
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
ok_sequence(sequences, COMBINED_SEQ_INDEX, set_focus_default_seq, "WM_SETFOCUS on default radiobutton", TRUE);
ok_sequence(sequences, COMBINED_SEQ_INDEX, set_focus_default_seq, "WM_SETFOCUS on default radiobutton", FALSE);
DestroyWindow(button);
/* Test already checked button */
@ -2542,7 +2542,7 @@ static void test_radiobutton_focus(void)
flush_sequences(sequences, NUM_MSG_SEQUENCES);
SendMessageA(button, WM_SETFOCUS, 0, 0);
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
ok_sequence(sequences, COMBINED_SEQ_INDEX, set_focus_default_seq, "WM_SETFOCUS on focused radiobutton", TRUE);
ok_sequence(sequences, COMBINED_SEQ_INDEX, set_focus_default_seq, "WM_SETFOCUS on focused radiobutton", FALSE);
DestroyWindow(button);
/* Test WM_LBUTTONDOWN */
@ -2562,7 +2562,7 @@ static void test_radiobutton_focus(void)
flush_sequences(sequences, NUM_MSG_SEQUENCES);
SendMessageA(button, WM_SETFOCUS, 0, 0);
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
ok_sequence(sequences, COMBINED_SEQ_INDEX, set_focus_without_notify_seq, "WM_SETFOCUS on radiobutton withouth BS_NOTIFY", TRUE);
ok_sequence(sequences, COMBINED_SEQ_INDEX, set_focus_without_notify_seq, "WM_SETFOCUS on radiobutton withouth BS_NOTIFY", FALSE);
DestroyWindow(button);
}