From a549da33e3dc5020558e8c2f62f706974d40a78b Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Tue, 14 Sep 2010 16:46:55 +0300 Subject: user32: Fix VK_RETURN handling in IsDialogMessage for dialogs without an IDOK This fixes #23453 (both the app and attached MFC test case), #21295 (but not #22544), and #23936. A test is included. --- dlls/user32/dialog.c | 10 +++++++--- dlls/user32/tests/dialog.c | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c index aac8a4d..8038719 100644 --- a/dlls/user32/dialog.c +++ b/dlls/user32/dialog.c @@ -1220,11 +1220,15 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg ) } else if (DC_HASDEFID == HIWORD(dw = SendMessageW (hwndDlg, DM_GETDEFID, 0, 0))) { + WPARAM wParam; HWND hwndDef = GetDlgItem(hwndDlg, LOWORD(dw)); - if (!hwndDef || !IsWindowEnabled(hwndDef)) + if (!hwndDef && LOWORD(dw)==IDOK) + wParam = IDOK; + else if (!hwndDef || !IsWindowEnabled(hwndDef)) return TRUE; - SendMessageW( hwndDlg, WM_COMMAND, MAKEWPARAM( LOWORD(dw), BN_CLICKED ), - (LPARAM)GetDlgItem(hwndDlg, LOWORD(dw))); + else + wParam = MAKEWPARAM( LOWORD(dw), BN_CLICKED ); + SendMessageW( hwndDlg, WM_COMMAND, wParam, (LPARAM)hwndDef); } else { diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c index b7727da..736c99d 100644 --- a/dlls/user32/tests/dialog.c +++ b/dlls/user32/tests/dialog.c @@ -1000,6 +1000,28 @@ static INT_PTR CALLBACK TestDefButtonDlgProc (HWND hDlg, UINT uiMsg, return FALSE; } +static INT_PTR CALLBACK TestReturnKeyDlgProc (HWND hDlg, UINT uiMsg, + WPARAM wParam, LPARAM lParam) +{ + static int received_idok = 0; + switch (uiMsg) + { + case WM_INITDIALOG: + { + MSG msg = {hDlg, WM_KEYDOWN, VK_RETURN, 0x011c0001}; + IsDialogMessage(hDlg, &msg); + } + ok(received_idok, "WM_COMMAND not received\n"); + EndDialog(hDlg, 0); + return TRUE; + case WM_COMMAND: + ok(wParam==IDOK, "Expected IDOK\n"); + received_idok = 1; + return TRUE; + } + return FALSE; +} + static void test_DialogBoxParamA(void) { INT_PTR ret; @@ -1044,6 +1066,8 @@ static void test_DialogBoxParamA(void) ret = DialogBoxParamA(GetModuleHandle(NULL), "TEST_EMPTY_DIALOG", 0, TestDefButtonDlgProc, 0); ok(ret == IDOK, "Expected IDOK\n"); + + DialogBoxParamA(GetModuleHandle(NULL), "TEST_EMPTY_DIALOG", 0, TestReturnKeyDlgProc, 0); } static void test_DisabledDialogTest(void) -- 1.7.0.4