Commit 608aa7f3 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

user32: Send notification for the focused button in IsDialogMessage().

When handling WM_KEYDOWN,VK_RETURN messages from a dialog hwnd in IsDialogMessage(), if the focused button is in the dialog, send a BN_CLICKED notification to the dialog proc. This also make it possible for the default button with an id larger than 0xFFFF in the dialog to receive the correct BN_CLICKED notification, which has a null lParam before this. Signed-off-by: 's avatarZhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 8318b11d
......@@ -1252,10 +1252,11 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
case VK_RETURN:
{
DWORD dw;
if ((GetFocus() == msg->hwnd) &&
(SendMessageW (msg->hwnd, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON))
HWND hwndFocus = GetFocus();
if (IsChild( hwndDlg, hwndFocus ) &&
(SendMessageW( hwndFocus, WM_GETDLGCODE, 0, 0 ) & DLGC_DEFPUSHBUTTON))
{
SendMessageW (hwndDlg, WM_COMMAND, MAKEWPARAM (GetDlgCtrlID(msg->hwnd),BN_CLICKED), (LPARAM)msg->hwnd);
SendMessageW( hwndDlg, WM_COMMAND, MAKEWPARAM( GetDlgCtrlID( hwndFocus ), BN_CLICKED ), (LPARAM)hwndFocus );
}
else if (DC_HASDEFID == HIWORD(dw = SendMessageW (hwndDlg, DM_GETDEFID, 0, 0)))
{
......@@ -1266,7 +1267,6 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
else
{
SendMessageW( hwndDlg, WM_COMMAND, IDOK, (LPARAM)GetDlgItem( hwndDlg, IDOK ) );
}
}
return TRUE;
......
......@@ -55,6 +55,7 @@ static LONG g_styleInitialFocusT1, g_styleInitialFocusT2;
static BOOL g_bInitialFocusInitDlgResult, g_bReceivedCommand;
static BOOL g_terminated;
static BOOL g_button1Clicked;
typedef struct {
INT_PTR id;
......@@ -474,6 +475,10 @@ static LRESULT CALLBACK main_window_procA (HWND hwnd, UINT uiMsg, WPARAM wParam,
g_terminated = TRUE;
return 0;
}
else if ((wParam == 100 || wParam == 0xFFFF) && lParam)
{
g_button1Clicked = TRUE;
}
break;
}
......@@ -788,6 +793,33 @@ static void test_IsDialogMessage(void)
UnhookWindowsHookEx(hook);
DestroyWindow(g_hwndMain);
g_hwndMain = CreateWindowA("IsDialogMessageWindowClass", "IsDialogMessageWindowClass", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, g_hinst, 0);
SetFocus(g_hwndButton1);
g_button1Clicked = FALSE;
FormEnterMsg(&msg, g_hwndButton1);
ok(IsDialogMessageA(g_hwndMain, &msg), "Did not handle the ENTER\n");
ok(g_button1Clicked, "Did not receive button 1 click notification\n");
g_button1Clicked = FALSE;
FormEnterMsg(&msg, g_hwndMain);
ok(IsDialogMessageA(g_hwndMain, &msg), "Did not handle the ENTER\n");
ok(g_button1Clicked, "Did not receive button 1 click notification\n");
g_button1Clicked = FALSE;
FormEnterMsg(&msg, g_hwndButton2);
ok(IsDialogMessageA(g_hwndMain, &msg), "Did not handle the ENTER\n");
ok(g_button1Clicked, "Did not receive button 1 click notification\n");
/* Button with id larger than 0xFFFF should also work */
g_button1Clicked = FALSE;
FormEnterMsg(&msg, g_hwndMain);
SetWindowLongPtrW(g_hwndButton1, GWLP_ID, 0x1FFFF);
ok(IsDialogMessageA(g_hwndMain, &msg), "Did not handle the ENTER\n");
ok(g_button1Clicked, "Did not receive button 1 click notification\n");
DestroyWindow(g_hwndMain);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment