Lei Zhang : user32: Dialog should ignore WM_KEYDOWN messages if it gets DLGC_WANTCHARS.
Alexandre Julliard
julliard at winehq.org
Thu Apr 3 05:43:49 CDT 2008
Module: wine
Branch: master
Commit: 08a4d2afc2ddfc1e508ef8528d5332d4b915b0a0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=08a4d2afc2ddfc1e508ef8528d5332d4b915b0a0
Author: Lei Zhang <thestig at google.com>
Date: Wed Apr 2 11:04:23 2008 -0700
user32: Dialog should ignore WM_KEYDOWN messages if it gets DLGC_WANTCHARS.
---
dlls/user32/dialog.c | 2 +-
dlls/user32/tests/edit.c | 103 +++++++++++++++++++++++++++++++++++++++++
dlls/user32/tests/resource.rc | 10 ++++
3 files changed, 114 insertions(+), 1 deletions(-)
diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index bb0d460..243bb5a 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -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)
{
diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c
index a40251c..123fd4f 100644
--- a/dlls/user32/tests/edit.c
+++ b/dlls/user32/tests/edit.c
@@ -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();
}
diff --git a/dlls/user32/tests/resource.rc b/dlls/user32/tests/resource.rc
index b0c4967..24c5e33 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
+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"
More information about the wine-cvs
mailing list