user32: Tweak how the edit control handles WM_GETDLGCODE.

This commit is contained in:
Lei Zhang 2008-03-25 19:09:38 -07:00 committed by Alexandre Julliard
parent a1bc05e4c0
commit 41ea8f0e8a
3 changed files with 110 additions and 9 deletions

View File

@ -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:

View File

@ -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();
}

View File

@ -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