diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index b1a0007598f..0ff4e7cf960 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -795,21 +795,36 @@ static LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg, 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 (es->hwndListBox && (vk == VK_RETURN || vk == VK_ESCAPE)) - { - if (SendMessageW(GetParent(hwnd), CB_GETDROPPEDSTATE, 0, 0)) - result |= DLGC_WANTMESSAGE; - } - } + 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_RETURN: + SendMessageW(GetParent(hwnd), WM_COMMAND, IDOK, (LPARAM)GetDlgItem(GetParent(hwnd), IDOK)); + break; + case VK_ESCAPE: + SendMessageW(GetParent(hwnd), WM_CLOSE, 0, 0); + break; + case VK_TAB: + SendMessageW(GetParent(hwnd), WM_NEXTDLGCTL, (GetKeyState(VK_SHIFT) & 0x8000), 0); + break; + default: + break; + } + } + } break; case WM_IME_CHAR: diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c index fae1bd121b5..05e6741e39c 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -37,6 +37,70 @@ struct edit_notify { static struct edit_notify notifications; +static INT_PTR CALLBACK bug_11841_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) +{ + switch (msg) + { + case WM_INITDIALOG: + { + SetFocus(GetDlgItem(hdlg, 1000)); + switch (lparam) + { + case 0: + PostMessage(GetDlgItem(hdlg, 1000), WM_KEYDOWN, 0x1b, 0x10001); + break; + case 1: + PostMessage(GetDlgItem(hdlg, 1000), WM_KEYDOWN, 0xd, 0x1c0001); + break; + case 2: + PostMessage(GetDlgItem(hdlg, 1000), WM_KEYDOWN, 0x9, 0xf0001); + PostMessage(hdlg, WM_USER, 0xdeadbeef, 0xdeadbeef); + break; + default: + break; + } + break; + } + + case WM_COMMAND: + if (HIWORD(wparam) != BN_CLICKED) + break; + + switch (LOWORD(wparam)) + { + case IDOK: + EndDialog(hdlg, 111); + break; + + case IDCANCEL: + EndDialog(hdlg, 222); + break; + + default: + break; + } + break; + + case WM_USER: + if (wparam != 0xdeadbeef || lparam != 0xdeadbeef) + break; + if (GetFocus() == GetDlgItem(hdlg, IDOK)) + EndDialog(hdlg, 444); + else + EndDialog(hdlg, 555); + break; + + case WM_CLOSE: + EndDialog(hdlg, 333); + break; + + default: + break; + } + + return FALSE; +} + static HINSTANCE hinst; static HWND hwndET2; static const char szEditTest2Class[] = "EditTest2Class"; @@ -1134,6 +1198,17 @@ static void test_undo(void) DestroyWindow (hwEdit); } +static void test_bug_11841(void) +{ + int r; + r = DialogBoxParam(hinst, "BUG_11841_DIALOG", NULL, (DLGPROC)bug_11841_proc, 0); + ok(333 == r, "Expected %d, got %d\n", 333, r); + r = DialogBoxParam(hinst, "BUG_11841_DIALOG", NULL, (DLGPROC)bug_11841_proc, 1); + ok(111 == r, "Expected %d, got %d\n", 111, r); + r = DialogBoxParam(hinst, "BUG_11841_DIALOG", NULL, (DLGPROC)bug_11841_proc, 2); + ok(444 == r, "Expected %d, got %d\n", 444, r); +} + static BOOL RegisterWindowClasses (void) { WNDCLASSA test2; @@ -1202,6 +1277,7 @@ START_TEST(edit) test_text_position(); test_espassword(); test_undo(); + test_bug_11841(); UnregisterWindowClasses(); } diff --git a/dlls/user32/tests/resource.rc b/dlls/user32/tests/resource.rc index f01c6f5344c..a68857f3d85 100644 --- a/dlls/user32/tests/resource.rc +++ b/dlls/user32/tests/resource.rc @@ -98,6 +98,16 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14 END +BUG_11841_DIALOG DIALOG DISCARDABLE 0, 0, 160, 80 +STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | DS_CENTER +CAPTION "Bug 11841 Test" +FONT 8, "MS Shell Dlg" +{ + PUSHBUTTON "Ok", IDOK, 20, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP + PUSHBUTTON "Cancel", IDCANCEL, 100, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP + EDITTEXT 1000, 5, 5, 150, 50, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL | ES_READONLY +} + /* @makedep: test_mono.bmp */ 100 BITMAP test_mono.bmp