From 592d994f0077c19dc9fa2db988f70d5d4c2a9cdb Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Tue, 14 Sep 2010 16:46:55 +0300 Subject: [PATCH] user32: Fix VK_RETURN handling in IsDialogMessage for dialogs without an IDOK. --- dlls/user32/dialog.c | 6 ++---- dlls/user32/tests/dialog.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c index aac8a4ded6e..052fbff04cc 100644 --- a/dlls/user32/dialog.c +++ b/dlls/user32/dialog.c @@ -1221,10 +1221,8 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg ) else if (DC_HASDEFID == HIWORD(dw = SendMessageW (hwndDlg, DM_GETDEFID, 0, 0))) { HWND hwndDef = GetDlgItem(hwndDlg, LOWORD(dw)); - if (!hwndDef || !IsWindowEnabled(hwndDef)) - return TRUE; - SendMessageW( hwndDlg, WM_COMMAND, MAKEWPARAM( LOWORD(dw), BN_CLICKED ), - (LPARAM)GetDlgItem(hwndDlg, LOWORD(dw))); + if (hwndDef ? IsWindowEnabled(hwndDef) : LOWORD(dw)==IDOK) + SendMessageW( hwndDlg, WM_COMMAND, MAKEWPARAM( LOWORD(dw), BN_CLICKED ), (LPARAM)hwndDef); } else { diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c index b7727da4d47..736c99d784e 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)