user32: Dialog should ignore WM_KEYDOWN messages if it gets DLGC_WANTCHARS.

This commit is contained in:
Lei Zhang 2008-04-02 11:04:23 -07:00 committed by Alexandre Julliard
parent 1d1f1373af
commit 08a4d2afc2
3 changed files with 114 additions and 1 deletions

View File

@ -1094,7 +1094,7 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
{
case WM_KEYDOWN:
dlgCode = SendMessageW( msg->hwnd, WM_GETDLGCODE, msg->wParam, (LPARAM)msg );
if (dlgCode & DLGC_WANTMESSAGE) break;
if (dlgCode & (DLGC_WANTCHARS|DLGC_WANTMESSAGE)) break;
switch(msg->wParam)
{

View File

@ -37,6 +37,95 @@ struct edit_notify {
static struct edit_notify notifications;
static INT_PTR CALLBACK multi_edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_INITDIALOG:
{
HWND hedit = GetDlgItem(hdlg, 1000);
SetFocus(hedit);
switch (lparam)
{
/* test cases related to bug 12319 */
case 0:
PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
break;
case 1:
PostMessage(hedit, WM_CHAR, VK_TAB, 0xf0001);
PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
break;
case 2:
PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
PostMessage(hedit, WM_CHAR, VK_TAB, 0xf0001);
PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
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:
{
HWND hfocus = GetFocus();
HWND hedit = GetDlgItem(hdlg, 1000);
HWND hedit2 = GetDlgItem(hdlg, 1001);
HWND hedit3 = GetDlgItem(hdlg, 1002);
if (wparam != 0xdeadbeef)
break;
switch (lparam)
{
case 0:
if (hfocus == hedit)
EndDialog(hdlg, 1111);
else if (hfocus == hedit2)
EndDialog(hdlg, 2222);
else if (hfocus == hedit3)
EndDialog(hdlg, 3333);
else
EndDialog(hdlg, 4444);
break;
default:
EndDialog(hdlg, 5555);
}
break;
}
case WM_CLOSE:
EndDialog(hdlg, 333);
break;
default:
break;
}
return FALSE;
}
static INT_PTR CALLBACK edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
@ -1341,6 +1430,19 @@ static void test_edit_dialog(void)
ok(33 == r, "Expected %d, got %d\n", 33, r);
}
static void test_multi_edit_dialog(void)
{
int r;
/* test for multiple edit dialogs (bug 12319) */
r = DialogBoxParam(hinst, "MULTI_EDIT_DIALOG", NULL, (DLGPROC)multi_edit_dialog_proc, 0);
ok(2222 == r, "Expected %d, got %d\n", 2222, r);
r = DialogBoxParam(hinst, "MULTI_EDIT_DIALOG", NULL, (DLGPROC)multi_edit_dialog_proc, 1);
ok(1111 == r, "Expected %d, got %d\n", 1111, r);
r = DialogBoxParam(hinst, "MULTI_EDIT_DIALOG", NULL, (DLGPROC)multi_edit_dialog_proc, 2);
ok(2222 == r, "Expected %d, got %d\n", 2222, r);
}
static BOOL RegisterWindowClasses (void)
{
WNDCLASSA test2;
@ -1410,6 +1512,7 @@ START_TEST(edit)
test_espassword();
test_undo();
test_edit_dialog();
test_multi_edit_dialog();
UnregisterWindowClasses();
}

View File

@ -98,6 +98,16 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
END
MULTI_EDIT_DIALOG DIALOG DISCARDABLE 0, 0, 160, 75
STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | DS_CENTER
CAPTION "Multiple Edit Test"
FONT 8, "MS Shell Dlg"
{
EDITTEXT 1000, 5, 5, 150, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
EDITTEXT 1001, 5, 25, 150, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
EDITTEXT 1002, 5, 45, 150, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
}
EDIT_DIALOG DIALOG DISCARDABLE 0, 0, 160, 80
STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | DS_CENTER
CAPTION "Edit Test"