Dmitry Timoshkov : user32: IsDialogMessage should allow control ids other than IDOK when processing WM_KEYDOWN .
Alexandre Julliard
julliard at winehq.org
Thu Mar 29 15:48:58 CDT 2012
Module: wine
Branch: master
Commit: 38387dcffedc7e04f85201af9bcd9214eb428ae3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=38387dcffedc7e04f85201af9bcd9214eb428ae3
Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date: Wed Mar 28 14:11:55 2012 +0900
user32: IsDialogMessage should allow control ids other than IDOK when processing WM_KEYDOWN.
---
dlls/user32/dialog.c | 2 +-
dlls/user32/tests/dialog.c | 34 ++++++++++++++++++++++++++--------
2 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index 95e9e88..f0fdf49 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -1278,7 +1278,7 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
else if (DC_HASDEFID == HIWORD(dw = SendMessageW (hwndDlg, DM_GETDEFID, 0, 0)))
{
HWND hwndDef = DIALOG_IdToHwnd(hwndDlg, LOWORD(dw));
- if (hwndDef ? IsWindowEnabled(hwndDef) : LOWORD(dw)==IDOK)
+ if (!hwndDef || IsWindowEnabled(hwndDef))
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 404aeee..6bd34b3 100644
--- a/dlls/user32/tests/dialog.c
+++ b/dlls/user32/tests/dialog.c
@@ -1065,20 +1065,38 @@ static INT_PTR CALLBACK TestDefButtonDlgProc (HWND hDlg, UINT uiMsg,
static INT_PTR CALLBACK TestReturnKeyDlgProc (HWND hDlg, UINT uiMsg,
WPARAM wParam, LPARAM lParam)
{
- static int received_idok = 0;
+ static int received_idok;
+
switch (uiMsg)
{
case WM_INITDIALOG:
- {
- MSG msg = {hDlg, WM_KEYDOWN, VK_RETURN, 0x011c0001};
- IsDialogMessage(hDlg, &msg);
- }
- ok(received_idok, "WM_COMMAND not received\n");
+ {
+ MSG msg = {hDlg, WM_KEYDOWN, VK_RETURN, 0x011c0001};
+
+ received_idok = -1;
+ IsDialogMessage(hDlg, &msg);
+ ok(received_idok == 0xdead, "WM_COMMAND/0xdead not received\n");
+
+ received_idok = -2;
+ IsDialogMessage(hDlg, &msg);
+ ok(received_idok == IDOK, "WM_COMMAND/IDOK not received\n");
+
EndDialog(hDlg, 0);
return TRUE;
+ }
+
+ case DM_GETDEFID:
+ if (received_idok == -1)
+ {
+ HWND hwnd = GetDlgItem(hDlg, 0xdead);
+ ok(!hwnd, "dialog item with ID 0xdead should not exist\n");
+ SetWindowLong(hDlg, DWLP_MSGRESULT, MAKELRESULT(0xdead, DC_HASDEFID));
+ return TRUE;
+ }
+ return FALSE;
+
case WM_COMMAND:
- ok(wParam==IDOK, "Expected IDOK\n");
- received_idok = 1;
+ received_idok = wParam;
return TRUE;
}
return FALSE;
More information about the wine-cvs
mailing list