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

Alexandre Julliard julliard at winehq.org
Mon Jul 16 14:40:01 CDT 2018


Module: wine
Branch: master
Commit: 608aa7f3d743ffdf4072cfb0cbb7780bda44559d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=608aa7f3d743ffdf4072cfb0cbb7780bda44559d

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Mon Jul 16 15:48:14 2018 +0800

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: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/dialog.c       |  8 ++++----
 dlls/user32/tests/dialog.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index 6f23c74..e584cc1 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 (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 e1fe803..0604423 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,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);
 }
 
 




More information about the wine-cvs mailing list