user32: edit: Improve handling of WM_KEYDOWN VK_RETURN in a dialog mode.
diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
index eef07da..83e004a 100644
--- a/dlls/user32/edit.c
+++ b/dlls/user32/edit.c
@@ -3619,21 +3619,20 @@
/* If the edit doesn't want the return send a message to the default object */
if(!(es->style & ES_MULTILINE) || !(es->style & ES_WANTRETURN))
{
- HWND hwndParent;
- DWORD dw;
+ DWORD dw;
- if (!EDIT_IsInsideDialog(es)) return 1;
+ if (!EDIT_IsInsideDialog(es)) break;
if (control) break;
- hwndParent = GetParent(es->hwndSelf);
- dw = SendMessageW( hwndParent, DM_GETDEFID, 0, 0 );
- if (HIWORD(dw) == DC_HASDEFID)
- {
- SendMessageW( hwndParent, WM_COMMAND,
- MAKEWPARAM( LOWORD(dw), BN_CLICKED ),
- (LPARAM)GetDlgItem( hwndParent, LOWORD(dw) ) );
- }
- else
- SendMessageW( hwndParent, WM_COMMAND, IDOK, (LPARAM)GetDlgItem( hwndParent, IDOK ) );
+ dw = SendMessageW(es->hwndParent, DM_GETDEFID, 0, 0);
+ if (HIWORD(dw) == DC_HASDEFID)
+ {
+ HWND hwDefCtrl = GetDlgItem(es->hwndParent, LOWORD(dw));
+ if (hwDefCtrl)
+ {
+ SendMessageW(es->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwDefCtrl, (LPARAM)TRUE);
+ PostMessageW(hwDefCtrl, WM_KEYDOWN, VK_RETURN, 0);
+ }
+ }
}
break;
case VK_ESCAPE: