[PATCH 2/9] user32: Send notification for the focused button in IsDialogMessage().
Zhiyi Zhang
zzhang at codeweavers.com
Mon Jul 16 02:48:14 CDT 2018
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: Zhiyi Zhang <zzhang at codeweavers.com>
---
dlls/user32/dialog.c | 8 ++++----
dlls/user32/tests/dialog.c | 27 +++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index 6f23c74309..4e45daa786 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -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 ((hwndFocus == msg->hwnd || 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;
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c
index e1fe8038f0..9a172ba9ea 100644
--- a/dlls/user32/tests/dialog.c
+++ b/dlls/user32/tests/dialog.c
@@ -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,28 @@ 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");
+
+ /* 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);
}
--
2.18.0
More information about the wine-devel
mailing list