Lei Zhang : user32: Do not send button click to dialog with disabled default button.
Alexandre Julliard
julliard at winehq.org
Thu Oct 25 08:38:49 CDT 2007
Module: wine
Branch: master
Commit: 7c2263ddc4c6326d79a9d7f246eeba7ca7d45c5f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7c2263ddc4c6326d79a9d7f246eeba7ca7d45c5f
Author: Lei Zhang <thestig at google.com>
Date: Thu Oct 25 00:36:54 2007 -0700
user32: Do not send button click to dialog with disabled default button.
---
dlls/user32/dialog.c | 3 ++
dlls/user32/tests/dialog.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index 9607dcc..d8cf63b 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -1183,6 +1183,9 @@ 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)));
}
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c
index afde292..718805e 100644
--- a/dlls/user32/tests/dialog.c
+++ b/dlls/user32/tests/dialog.c
@@ -488,6 +488,44 @@ static LRESULT CALLBACK main_window_procA (HWND hwnd, UINT uiMsg, WPARAM wParam,
return result;
}
+static LRESULT CALLBACK disabled_test_proc (HWND hwnd, UINT uiMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ LRESULT result;
+ DWORD dw;
+ HWND hwndOk;
+
+ switch (uiMsg)
+ {
+ case WM_INITDIALOG:
+ dw = SendMessage(hwnd, DM_GETDEFID, 0, 0);
+ assert(DC_HASDEFID == HIWORD(dw));
+ hwndOk = GetDlgItem(hwnd, LOWORD(dw));
+ assert(hwndOk);
+ EnableWindow(hwndOk, FALSE);
+
+ PostMessage(hwnd, WM_KEYDOWN, VK_RETURN, 0);
+ PostMessage(hwnd, WM_COMMAND, IDCANCEL, 0);
+ break;
+ case WM_COMMAND:
+ if (wParam == IDOK)
+ {
+ g_terminated = TRUE;
+ EndDialog(hwnd, 0);
+ return 0;
+ }
+ else if (wParam == IDCANCEL)
+ {
+ EndDialog(hwnd, 0);
+ return 0;
+ }
+ break;
+ }
+
+ result=DefWindowProcA (hwnd, uiMsg, wParam, lParam);
+ return result;
+}
+
static LRESULT CALLBACK testDlgWinProc (HWND hwnd, UINT uiMsg, WPARAM wParam,
LPARAM lParam)
{
@@ -876,6 +914,13 @@ static void test_DialogBoxParamA(void)
ok(ERROR_RESOURCE_NAME_NOT_FOUND == GetLastError(),"got %d, expected ERROR_RESOURCE_NAME_NOT_FOUND\n",GetLastError());
}
+static void test_DisabledDialogTest(void)
+{
+ g_terminated = FALSE;
+ DialogBoxParam(g_hinst, "IDD_DIALOG", NULL, (DLGPROC)disabled_test_proc, 0);
+ ok(FALSE == g_terminated, "dialog with disabled ok button has been terminated\n");
+}
+
START_TEST(dialog)
{
g_hinst = GetModuleHandleA (0);
@@ -888,4 +933,5 @@ START_TEST(dialog)
InitialFocusTest();
test_GetDlgItemText();
test_DialogBoxParamA();
+ test_DisabledDialogTest();
}
More information about the wine-cvs
mailing list