Sergey Khodych : user32: edit: Use a dialog mode after receiving WM_GETDLGCODE message.

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


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

Author: Sergey Khodych <khodych at gmail.com>
Date:   Mon Aug 24 00:10:01 2009 +0300

user32: edit: Use a dialog mode after receiving WM_GETDLGCODE message.

Tests show that the edit control uses a dialog mode after receiving 
WM_GETDLGCODE message and it doesn't depend on whether the edit control 
has a parent window.

---

 dlls/user32/edit.c       |   66 +++++++++++++++++++++-------------------------
 dlls/user32/tests/edit.c |   57 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+), 36 deletions(-)

diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
index eadcc3d..0cb8f11 100644
--- a/dlls/user32/edit.c
+++ b/dlls/user32/edit.c
@@ -83,6 +83,8 @@ WINE_DECLARE_DEBUG_CHANNEL(relay);
 #define EF_USE_SOFTBRK		0x0100	/* Enable soft breaks in text. */
 #define EF_APP_HAS_HANDLE       0x0200  /* Set when an app sends EM_[G|S]ETHANDLE.  We are in sole control of
                                            the text buffer if this is clear. */
+#define EF_DIALOGMODE           0x0400  /* Indicates that we are inside a dialog window */
+
 typedef enum
 {
 	END_0 = 0,			/* line ends with terminating '\0' character */
@@ -3163,22 +3165,9 @@ static BOOL EDIT_EM_Undo(EDITSTATE *es)
  * controls without ES_WANTRETURN would attempt to detect whether it is inside
  * a dialog box or not.
  */
-static BOOL EDIT_IsInsideDialog(EDITSTATE *es)
+static inline BOOL EDIT_IsInsideDialog(EDITSTATE *es)
 {
-    WND *pParent;
-    BOOL r = FALSE;
-
-    if (es->hwndParent)
-    {
-        pParent = WIN_GetPtr(es->hwndParent);
-        if (pParent && pParent != WND_OTHER_PROCESS && pParent != WND_DESKTOP)
-        {
-            if (pParent->flags & WIN_ISDIALOG)
-                r = TRUE;
-            WIN_ReleasePtr(pParent);
-        }
-    }
-    return r;
+    return (es->flags & EF_DIALOGMODE);
 }
 
 
@@ -5107,27 +5096,32 @@ static LRESULT EditWndProc_common( HWND hwnd, UINT msg,
 		if (es->style & ES_MULTILINE)
 		   result |= DLGC_WANTALLKEYS;
 
-		if (lParam && (((LPMSG)lParam)->message == WM_KEYDOWN))
-		{
-		   int vk = (int)((LPMSG)lParam)->wParam;
-
-                   if (es->hwndListBox)
-                   {
-                       if (vk == VK_RETURN || vk == VK_ESCAPE)
-                           if (SendMessageW(GetParent(hwnd), CB_GETDROPPEDSTATE, 0, 0))
-                               result |= DLGC_WANTMESSAGE;
-                   }
-                   else
-                   {
-                       switch (vk)
-                       {
-                           case VK_ESCAPE:
-                               SendMessageW(GetParent(hwnd), WM_CLOSE, 0, 0);
-                               break;
-                           default:
-                               break;
-                       }
-                   }
+                if (lParam)
+                {
+                    es->flags|=EF_DIALOGMODE;
+
+                    if (((LPMSG)lParam)->message == WM_KEYDOWN)
+                    {
+                        int vk = (int)((LPMSG)lParam)->wParam;
+
+                        if (es->hwndListBox)
+                        {
+                            if (vk == VK_RETURN || vk == VK_ESCAPE)
+                                if (SendMessageW(GetParent(hwnd), CB_GETDROPPEDSTATE, 0, 0))
+                                    result |= DLGC_WANTMESSAGE;
+                        }
+                        else
+                        {
+                            switch (vk)
+                            {
+                                case VK_ESCAPE:
+                                    SendMessageW(GetParent(hwnd), WM_CLOSE, 0, 0);
+                                    break;
+                                default:
+                                    break;
+                            }
+                        }
+                  }
                 }
 		break;
 
diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c
index 399ec4c..d8f6922 100644
--- a/dlls/user32/tests/edit.c
+++ b/dlls/user32/tests/edit.c
@@ -2081,6 +2081,62 @@ static void test_fontsize(void)
     DeleteObject(hfont);
 }
 
+static void test_dialogmode(void)
+{
+    HWND hwEdit;
+    MSG msg= {0};
+    int len, r;
+    hwEdit = create_child_editcontrol(ES_MULTILINE, 0);
+
+    r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
+    ok(1 == r, "expected 1, got %d\n", r);
+    len = SendMessage(hwEdit, WM_GETTEXTLENGTH, 0, 0);
+    ok(11 == len, "expected 11, got %d\n", len);
+
+    r = SendMessage(hwEdit, WM_GETDLGCODE, (WPARAM)NULL, (LPARAM)NULL);
+    ok(0x8d == r, "expected 0x8d, got 0x%x\n", r);
+
+    r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
+    ok(1 == r, "expected 1, got %d\n", r);
+    len = SendMessage(hwEdit, WM_GETTEXTLENGTH, 0, 0);
+    ok(13 == len, "expected 13, got %d\n", len);
+
+    r = SendMessage(hwEdit, WM_GETDLGCODE, (WPARAM)NULL, (LPARAM)&msg);
+    ok(0x8d == r, "expected 0x8d, got 0x%x\n", r);
+    r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
+    ok(1 == r, "expected 1, got %d\n", r);
+    len = SendMessage(hwEdit, WM_GETTEXTLENGTH, 0, 0);
+    ok(13 == len, "expected 13, got %d\n", len);
+
+    r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
+    ok(1 == r, "expected 1, got %d\n", r);
+    len = SendMessage(hwEdit, WM_GETTEXTLENGTH, 0, 0);
+    ok(13 == len, "expected 13, got %d\n", len);
+
+    destroy_child_editcontrol(hwEdit);
+
+    hwEdit = create_editcontrol(ES_MULTILINE, 0);
+
+    r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
+    ok(1 == r, "expected 1, got %d\n", r);
+    len = SendMessage(hwEdit, WM_GETTEXTLENGTH, 0, 0);
+    ok(11 == len, "expected 11, got %d\n", len);
+
+    msg.hwnd = hwEdit;
+    msg.message = WM_KEYDOWN;
+    msg.wParam = VK_BACK;
+    msg.lParam = 0xe0001;
+    r = SendMessage(hwEdit, WM_GETDLGCODE, VK_BACK, (LPARAM)&msg);
+    ok(0x8d == r, "expected 0x8d, got 0x%x\n", r);
+
+    r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
+    ok(1 == r, "expected 1, got %d\n", r);
+    len = SendMessage(hwEdit, WM_GETTEXTLENGTH, 0, 0);
+    ok(11 == len, "expected 11, got %d\n", len);
+
+    DestroyWindow(hwEdit);
+}
+
 START_TEST(edit)
 {
     hinst = GetModuleHandleA(NULL);
@@ -2105,6 +2161,7 @@ START_TEST(edit)
     test_singleline_wantreturn_edit_dialog();
     test_child_edit_wmkeydown();
     test_fontsize();
+    test_dialogmode();
 
     UnregisterWindowClasses();
 }




More information about the wine-cvs mailing list