Edit - wants all keys when multiline (take 2)

Vitaliy Margolen wine-patch at kievinfo.com
Mon Nov 1 12:28:11 CST 2004


Ok, this time with suggestions from Dmitry.

Vitaliy Margolen

changelog:
  dlls/user32/edit.c
  - return "want all keys" if multi-line
  - single line edit does not want all messages
  - additional style combinations are possible from both multi-line
     and single-line edit controls
  - tests to confirm it
-------------- next part --------------
Index: edit.c
===================================================================
RCS file: /home/wine/wine/dlls/user/edit.c,v
retrieving revision 1.3
diff -u -r1.3 edit.c
--- edit.c	16 Sep 2004 20:28:10 -0000	1.3
+++ edit.c	1 Nov 2004 18:16:53 -0000
@@ -761,16 +761,18 @@
 
 	case WM_GETDLGCODE:
 		result = DLGC_HASSETSEL | DLGC_WANTCHARS | DLGC_WANTARROWS;
+		
+		if (es->style & ES_MULTILINE)
+		{
+		   result |= DLGC_WANTALLKEYS;
+		   break;
+		}
 
 		if (lParam && (((LPMSG)lParam)->message == WM_KEYDOWN))
 		{
 		   int vk = (int)((LPMSG)lParam)->wParam;
 
-		   if (vk == VK_RETURN && (GetWindowLongW( hwnd, GWL_STYLE ) & ES_WANTRETURN))
-		   {
-		      result |= DLGC_WANTMESSAGE;
-		   }
-		   else if (es->hwndListBox && (vk == VK_RETURN || vk == VK_ESCAPE))
+		   if (es->hwndListBox && (vk == VK_RETURN || vk == VK_ESCAPE))
 		   {
 		      if (SendMessageW(GetParent(hwnd), CB_GETDROPPEDSTATE, 0, 0))
 		         result |= DLGC_WANTMESSAGE;
@@ -4386,7 +4388,6 @@
 			if (es->style & ES_RIGHT)
 				es->style &= ~ES_CENTER;
 			es->style &= ~WS_HSCROLL;
-			es->style &= ~ES_AUTOHSCROLL;
 		}
 
 		/* FIXME: for now, all multi line controls are AUTOVSCROLL */
@@ -4397,8 +4398,6 @@
 		es->style &= ~ES_RIGHT;
 		es->style &= ~WS_HSCROLL;
 		es->style &= ~WS_VSCROLL;
-		es->style &= ~ES_AUTOVSCROLL;
-		es->style &= ~ES_WANTRETURN;
 		if (es->style & ES_PASSWORD)
 			es->password_char = '*';
 
Index: tests/win.c
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/win.c,v
retrieving revision 1.35
diff -u -r1.35 win.c
--- tests/win.c	23 Sep 2004 22:52:26 -0000	1.35
+++ tests/win.c	1 Nov 2004 18:16:53 -0000
@@ -2060,6 +2060,103 @@
     ok(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "message %04x available\n", msg.message);
 }
 
+HWND create_editcontrol (DWORD style)
+{
+    HWND handle;
+
+    handle = CreateWindow("EDIT",
+			  NULL,
+			  ES_AUTOHSCROLL | ES_AUTOVSCROLL | style,
+			  10, 10, 300, 300,
+			  NULL, NULL, NULL, NULL);
+    assert (handle);
+    return handle;
+}
+
+static LONG get_edit_style (HWND hwnd)
+{
+    return GetWindowLongA( hwnd, GWL_STYLE ) & (
+	ES_LEFT |
+/* TODO:
+	ES_CENTER |
+	ES_RIGHT |
+	ES_OEMCONVERT |
+*/
+	ES_MULTILINE |
+	ES_UPPERCASE |
+	ES_LOWERCASE |
+	ES_PASSWORD |
+	ES_AUTOVSCROLL |
+	ES_AUTOHSCROLL |
+	ES_NOHIDESEL |
+	ES_COMBO |
+	ES_READONLY |
+	ES_WANTRETURN |
+	ES_NUMBER
+	);
+}
+static void test_edit_control(void)
+{
+    HWND hwEdit;
+    MSG msMessage;
+    int i;
+    LONG r;
+
+    msMessage.message = WM_KEYDOWN;
+
+    trace("EDIT: Single line\n");
+    hwEdit = create_editcontrol(0);
+    r = get_edit_style(hwEdit);
+    ok(r == (ES_AUTOVSCROLL | ES_AUTOHSCROLL), "Wrong style expected 0xc0 got: 0x%lx\n", r); 
+    for (i=0;i<65535;i++)
+    {
+	msMessage.wParam = i;
+	r = SendMessage(hwEdit, WM_GETDLGCODE, 0, (LPARAM) &msMessage);
+	ok(r == (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS),
+	    "Expected DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS got %lx\n", r);
+    }
+    DestroyWindow (hwEdit);
+
+    trace("EDIT: Single line want returns\n");
+    hwEdit = create_editcontrol(ES_WANTRETURN);
+    r = get_edit_style(hwEdit);
+    ok(r == (ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN), "Wrong style expected 0x10c0 got: 0x%lx\n", r); 
+    for (i=0;i<65535;i++)
+    {
+	msMessage.wParam = i;
+	r = SendMessage(hwEdit, WM_GETDLGCODE, 0, (LPARAM) &msMessage);
+	ok(r == (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS),
+	    "Expected DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS got %lx\n", r);
+    }
+    DestroyWindow (hwEdit);
+
+    trace("EDIT: Multiline line\n");
+    hwEdit = create_editcontrol(ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL);
+    r = get_edit_style(hwEdit);
+    ok(r == (ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE), "Wrong style expected 0xc4 got: 0x%lx\n", r); 
+    for (i=0;i<65535;i++)
+    {
+	msMessage.wParam = i;
+	r = SendMessage(hwEdit, WM_GETDLGCODE, 0, (LPARAM) &msMessage);
+	ok(r == (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTALLKEYS | DLGC_WANTARROWS),
+	    "Expected DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTALLKEYS | DLGC_WANTARROWS got %lx\n", r);
+    }
+    DestroyWindow (hwEdit);
+
+    trace("EDIT: Multi line want returns\n");
+    hwEdit = create_editcontrol(ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL | ES_WANTRETURN);
+    r = get_edit_style(hwEdit);
+    ok(r == (ES_WANTRETURN | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE), "Wrong style expected 0x10c4 got: 0x%lx\n", r); 
+    for (i=0;i<65535;i++)
+    {
+	msMessage.wParam = i;
+	r = SendMessage(hwEdit, WM_GETDLGCODE, 0, (LPARAM) &msMessage);
+	ok(r == (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTALLKEYS | DLGC_WANTARROWS),
+	    "Expected DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTALLKEYS | DLGC_WANTARROWS got %lx\n", r);
+    }
+    DestroyWindow (hwEdit);
+}
+
 START_TEST(win)
 {
     pGetAncestor = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" );
@@ -2116,4 +2213,6 @@
     test_keyboard_input(hwndMain);
 
     UnhookWindowsHookEx(hhook);
+
+    test_edit_control();
 }


More information about the wine-patches mailing list