Sergey Khodych : user32: edit: Improve handling of WM_KEYDOWN VK_RETURN in a dialog mode.

Alexandre Julliard julliard at winehq.org
Wed Aug 26 10:45:46 CDT 2009


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

Author: Sergey Khodych <khodych at gmail.com>
Date:   Tue Aug 25 18:01:05 2009 +0300

user32: edit: Improve handling of WM_KEYDOWN VK_RETURN in a dialog mode.

---

 dlls/user32/edit.c       |   25 ++++++++++++-------------
 dlls/user32/tests/edit.c |   24 ++++++++++++++++++++----
 2 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
index eef07da..83e004a 100644
--- a/dlls/user32/edit.c
+++ b/dlls/user32/edit.c
@@ -3619,21 +3619,20 @@ static LRESULT EDIT_WM_KeyDown(EDITSTATE *es, INT key)
 	    /* If the edit doesn't want the return send a message to the default object */
 	    if(!(es->style & ES_MULTILINE) || !(es->style & ES_WANTRETURN))
 	    {
-		HWND hwndParent;
-		DWORD dw;
+                DWORD dw;
 
-                if (!EDIT_IsInsideDialog(es)) return 1;
+                if (!EDIT_IsInsideDialog(es)) break;
                 if (control) break;
-                hwndParent = GetParent(es->hwndSelf);
-                dw = SendMessageW( hwndParent, DM_GETDEFID, 0, 0 );
-		if (HIWORD(dw) == DC_HASDEFID)
-		{
-		    SendMessageW( hwndParent, WM_COMMAND,
-				  MAKEWPARAM( LOWORD(dw), BN_CLICKED ),
- 			      (LPARAM)GetDlgItem( hwndParent, LOWORD(dw) ) );
-		}
-                else
-                    SendMessageW( hwndParent, WM_COMMAND, IDOK, (LPARAM)GetDlgItem( hwndParent, IDOK ) );
+                dw = SendMessageW(es->hwndParent, DM_GETDEFID, 0, 0);
+                if (HIWORD(dw) == DC_HASDEFID)
+                {
+                    HWND hwDefCtrl = GetDlgItem(es->hwndParent, LOWORD(dw));
+                    if (hwDefCtrl)
+                    {
+                        SendMessageW(es->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwDefCtrl, (LPARAM)TRUE);
+                        PostMessageW(hwDefCtrl, WM_KEYDOWN, VK_RETURN, 0);
+                    }
+                }
 	    }
 	    break;
         case VK_ESCAPE:
diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c
index 68afb27..f10b798 100644
--- a/dlls/user32/tests/edit.c
+++ b/dlls/user32/tests/edit.c
@@ -28,6 +28,7 @@
 #define ES_COMBO 0x200
 #endif
 
+#define ID_EDITTESTDBUTTON 0x123
 #define ID_EDITTEST2 99
 #define MAXLEN 200
 
@@ -1819,7 +1820,7 @@ static void test_edit_dialog(void)
     r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 6);
     ok(444 == r, "Expected %d, got %d\n", 444, r);
     r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 7);
-    todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r);
+    ok(444 == r, "Expected %d, got %d\n", 444, r);
     r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 8);
     ok(444 == r, "Expected %d, got %d\n", 444, r);
 
@@ -1843,7 +1844,7 @@ static void test_edit_dialog(void)
     r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 6);
     ok(444 == r, "Expected %d, got %d\n", 444, r);
     r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 7);
-    todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r);
+    ok(444 == r, "Expected %d, got %d\n", 444, r);
     r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 8);
     ok(444 == r, "Expected %d, got %d\n", 444, r);
 
@@ -2115,7 +2116,7 @@ static LRESULT CALLBACK dialog_mode_wnd_proc(HWND hwnd, UINT iMsg, WPARAM wParam
             break;
         case DM_GETDEFID:
             dm_messages.wm_getdefid++;
-            return 0;
+            return MAKELONG(ID_EDITTESTDBUTTON, DC_HASDEFID);
         case WM_NEXTDLGCTL:
             dm_messages.wm_nextdlgctl++;
             break;
@@ -2129,7 +2130,7 @@ static LRESULT CALLBACK dialog_mode_wnd_proc(HWND hwnd, UINT iMsg, WPARAM wParam
 
 static void test_dialogmode(void)
 {
-    HWND hwEdit, hwParent;
+    HWND hwEdit, hwParent, hwButton;
     MSG msg= {0};
     int len, r;
     hwEdit = create_child_editcontrol(ES_MULTILINE, 0);
@@ -2241,6 +2242,21 @@ static void test_dialogmode(void)
     test_dm_messages(0, 0, 0, 1);
     zero_dm_messages();
 
+    r = SendMessage(hwEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
+    ok(1 == r, "expected 1, got %d\n", r);
+    test_dm_messages(0, 0, 1, 0);
+    zero_dm_messages();
+
+    hwButton = CreateWindow("BUTTON", "OK", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,
+        100, 100, 50, 20, hwParent, (HMENU)ID_EDITTESTDBUTTON, hinst, NULL);
+    ok(hwButton!=NULL, "CreateWindow failed with error code %d\n", GetLastError());
+
+    r = SendMessage(hwEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
+    ok(1 == r, "expected 1, got %d\n", r);
+    test_dm_messages(0, 0, 1, 1);
+    zero_dm_messages();
+
+    DestroyWindow(hwButton);
     destroy_child_editcontrol(hwEdit);
 }
 




More information about the wine-cvs mailing list