- return "want all keys" for WM_GETDLGCODE when multi-line
- single-line edit control does not want all messages
- additional style combinations are possible for both multi-line and
  single-line edit controls
- tests to confirm it

diff --git a/dlls/user/edit.c b/dlls/user/edit.c
index 65080bc..ec2d7dc 100644
--- a/dlls/user/edit.c
+++ b/dlls/user/edit.c
@@ -779,16 +779,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;
@@ -4402,7 +4404,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 */
@@ -4413,8 +4414,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 = '*';
 
diff --git a/dlls/user/tests/.cvsignore b/dlls/user/tests/.cvsignore
index 4a6e3c5..fb8bdbd 100644
--- a/dlls/user/tests/.cvsignore
+++ b/dlls/user/tests/.cvsignore
@@ -3,6 +3,7 @@
 clipboard.ok
 dde.ok
 dialog.ok
+edit.ok
 generated.ok
 input.ok
 listbox.ok
diff --git a/dlls/user/tests/Makefile.in b/dlls/user/tests/Makefile.in
index dfcc827..0042283 100644
--- a/dlls/user/tests/Makefile.in
+++ b/dlls/user/tests/Makefile.in
@@ -10,6 +10,7 @@
 	clipboard.c \
 	dde.c \
 	dialog.c \
+	edit.c \
 	generated.c \
 	input.c \
 	listbox.c \
diff --git a/dlls/user/tests/edit.c b/dlls/user/tests/edit.c
new file mode 100644
index 0000000..a70bef9
--- /dev/null
+++ b/dlls/user/tests/edit.c
@@ -0,0 +1,129 @@
+/* Unit test suite for edit control.
+ *
+ * Copyright 2004 Vitaliy Margolen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <assert.h>
+#include <windows.h>
+#include <commctrl.h>
+
+#include "wine/test.h"
+
+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);
+    if (winetest_interactive)
+	ShowWindow (handle, SW_SHOW);
+    return handle;
+}
+
+static LONG get_edit_style (HWND hwnd)
+{
+    return GetWindowLongA( hwnd, GWL_STYLE ) & (
+	ES_LEFT |
+/* FIXME: not implemented
+	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(edit)
+{
+    test_edit_control();
+}