Lei Zhang : user32: Correctly handle VK_RETURN for edit controls with ES_WANTRETURN style.

Alexandre Julliard julliard at winehq.org
Thu Apr 3 05:43:49 CDT 2008


Module: wine
Branch: master
Commit: 376e45429cda0844b2106cc444a8cf7bac33de00
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=376e45429cda0844b2106cc444a8cf7bac33de00

Author: Lei Zhang <thestig at google.com>
Date:   Wed Apr  2 11:33:19 2008 -0700

user32: Correctly handle VK_RETURN for edit controls with ES_WANTRETURN style.

---

 dlls/user32/edit.c            |    5 ++---
 dlls/user32/tests/edit.c      |   22 +++++++++++++++++-----
 dlls/user32/tests/resource.rc |    2 +-
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
index dd5ba0a..e6d2530 100644
--- a/dlls/user32/edit.c
+++ b/dlls/user32/edit.c
@@ -811,9 +811,6 @@ static LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
                    {
                        switch (vk)
                        {
-                           case VK_RETURN:
-                               SendMessageW(GetParent(hwnd), WM_COMMAND, IDOK, (LPARAM)GetDlgItem(GetParent(hwnd), IDOK));
-                               break;
                            case VK_ESCAPE:
                                SendMessageW(GetParent(hwnd), WM_CLOSE, 0, 0);
                                break;
@@ -4608,6 +4605,8 @@ static LRESULT EDIT_WM_KeyDown(EDITSTATE *es, INT key)
 				  MAKEWPARAM( LOWORD(dw), BN_CLICKED ),
  			      (LPARAM)GetDlgItem( hwndParent, LOWORD(dw) ) );
 		}
+                else
+                    SendMessageW( hwndParent, WM_COMMAND, IDOK, (LPARAM)GetDlgItem( hwndParent, IDOK ) );
 	    }
 	    break;
 	}
diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c
index 123fd4f..0e9487d 100644
--- a/dlls/user32/tests/edit.c
+++ b/dlls/user32/tests/edit.c
@@ -39,6 +39,7 @@ static struct edit_notify notifications;
 
 static INT_PTR CALLBACK multi_edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
 {
+    static int num_ok_commands = 0;
     switch (msg)
     {
         case WM_INITDIALOG:
@@ -62,6 +63,13 @@ static INT_PTR CALLBACK multi_edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wpara
                     PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
                     break;
 
+                /* test cases for pressing enter */
+                case 3:
+                    num_ok_commands = 0;
+                    PostMessage(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
+                    PostMessage(hdlg, WM_USER, 0xdeadbeef, 1);
+                    break;
+
                 default:
                     break;
             }
@@ -75,11 +83,7 @@ static INT_PTR CALLBACK multi_edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wpara
             switch (LOWORD(wparam))
             {
                 case IDOK:
-                    EndDialog(hdlg, 111);
-                    break;
-
-                case IDCANCEL:
-                    EndDialog(hdlg, 222);
+                    num_ok_commands++;
                     break;
 
                 default:
@@ -109,6 +113,12 @@ static INT_PTR CALLBACK multi_edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wpara
                     else
                         EndDialog(hdlg, 4444);
                     break;
+                case 1:
+                    if ((hfocus == hedit) && (num_ok_commands == 0))
+                        EndDialog(hdlg, 11);
+                    else
+                        EndDialog(hdlg, 22);
+                    break;
                 default:
                     EndDialog(hdlg, 5555);
             }
@@ -1441,6 +1451,8 @@ static void test_multi_edit_dialog(void)
     ok(1111 == r, "Expected %d, got %d\n", 1111, r);
     r = DialogBoxParam(hinst, "MULTI_EDIT_DIALOG", NULL, (DLGPROC)multi_edit_dialog_proc, 2);
     ok(2222 == r, "Expected %d, got %d\n", 2222, r);
+    r = DialogBoxParam(hinst, "MULTI_EDIT_DIALOG", NULL, (DLGPROC)multi_edit_dialog_proc, 3);
+    ok(11 == r, "Expected %d, got %d\n", 11, r);
 }
 
 static BOOL RegisterWindowClasses (void)
diff --git a/dlls/user32/tests/resource.rc b/dlls/user32/tests/resource.rc
index 24c5e33..80abf08 100644
--- a/dlls/user32/tests/resource.rc
+++ b/dlls/user32/tests/resource.rc
@@ -103,7 +103,7 @@ STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | DS_CENTER
 CAPTION "Multiple Edit Test"
 FONT 8, "MS Shell Dlg"
 {
-    EDITTEXT 1000, 5, 5, 150, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+    EDITTEXT 1000, 5, 5, 150, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_MULTILINE | ES_WANTRETURN
     EDITTEXT 1001, 5, 25, 150, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
     EDITTEXT 1002, 5, 45, 150, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
 }




More information about the wine-cvs mailing list