Commit 142133ae authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

user32: Always enable owner window in EndDialog.

parent 26b37c40
...@@ -921,7 +921,6 @@ INT_PTR WINAPI DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW temp ...@@ -921,7 +921,6 @@ INT_PTR WINAPI DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW temp
*/ */
BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval ) BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval )
{ {
BOOL wasEnabled;
DIALOGINFO * dlgInfo; DIALOGINFO * dlgInfo;
HWND owner; HWND owner;
...@@ -934,10 +933,9 @@ BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval ) ...@@ -934,10 +933,9 @@ BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval )
} }
dlgInfo->idResult = retval; dlgInfo->idResult = retval;
dlgInfo->flags |= DF_END; dlgInfo->flags |= DF_END;
wasEnabled = (dlgInfo->flags & DF_OWNERENABLED);
owner = GetWindow( hwnd, GW_OWNER ); owner = GetWindow( hwnd, GW_OWNER );
if (wasEnabled && owner) if (owner)
DIALOG_EnableOwner( owner ); DIALOG_EnableOwner( owner );
/* Windows sets the focus to the dialog itself in EndDialog */ /* Windows sets the focus to the dialog itself in EndDialog */
...@@ -953,9 +951,7 @@ BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval ) ...@@ -953,9 +951,7 @@ BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval )
if (hwnd == GetActiveWindow()) if (hwnd == GetActiveWindow())
{ {
/* If this dialog was given an owner then set the focus to that owner /* If this dialog was given an owner then set the focus to that owner. */
even when the owner is disabled (normally when a window closes any
disabled windows cannot receive the focus). */
if (owner) if (owner)
SetForegroundWindow( owner ); SetForegroundWindow( owner );
else else
......
...@@ -12226,7 +12226,7 @@ static void test_EndDialog(void) ...@@ -12226,7 +12226,7 @@ static void test_EndDialog(void)
hother = CreateWindowExA(0, "TestParentClass", "Test parent 2", hother = CreateWindowExA(0, "TestParentClass", "Test parent 2",
WS_OVERLAPPEDWINDOW | WS_VISIBLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 200, 200, 0, 0, 0, NULL); 200, 100, 200, 200, 0, 0, 0, NULL);
ok (hother != 0, "Failed to create parent window\n"); ok (hother != 0, "Failed to create parent window\n");
ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n"); ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
...@@ -12240,20 +12240,40 @@ static void test_EndDialog(void) ...@@ -12240,20 +12240,40 @@ static void test_EndDialog(void)
hactive = GetForegroundWindow(); hactive = GetForegroundWindow();
ok(hother == hactive, "Wrong window has focus (%p != %p)\n", hother, hactive); ok(hother == hactive, "Wrong window has focus (%p != %p)\n", hother, hactive);
/* create a dialog where the parent is disabled, this parent should still /* create a dialog where the parent is disabled, this parent should be
receive the focus when the dialog exits (even though "normally" a * enabled and receive focus when dialog exits */
disabled window should not receive the focus) */
hdlg = CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", hparent, test_dlg_proc, 0); hdlg = CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", hparent, test_dlg_proc, 0);
ok(IsWindow(hdlg), "CreateDialogParam failed\n"); ok(IsWindow(hdlg), "CreateDialogParam failed\n");
SetForegroundWindow(hdlg); SetForegroundWindow(hdlg);
hactive = GetForegroundWindow(); hactive = GetForegroundWindow();
ok(hdlg == hactive, "Wrong window has focus (%p != %p)\n", hdlg, hactive); ok(hdlg == hactive, "Wrong window has focus (%p != %p)\n", hdlg, hactive);
EndDialog(hdlg, 0); EndDialog(hdlg, 0);
ok(IsWindowEnabled(hparent), "parent is not enabled\n");
hactive = GetForegroundWindow(); hactive = GetForegroundWindow();
ok(hparent == hactive, "Wrong window has focus (parent != active) (active: %p, parent: %p, dlg: %p, other: %p)\n", hactive, hparent, hdlg, hother); ok(hparent == hactive, "Wrong window has focus (parent != active) (active: %p, parent: %p, dlg: %p, other: %p)\n", hactive, hparent, hdlg, hother);
DestroyWindow(hdlg); DestroyWindow(hdlg);
flush_sequence(); flush_sequence();
/* create a dialog where the parent is disabled and set active window to other window before calling EndDialog */
EnableWindow(hparent, FALSE);
hdlg = CreateWindowExA(0, "TestDialogClass", NULL,
WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
0, 0, 100, 100, hparent, 0, 0, NULL);
ok(IsWindow(hdlg), "CreateDialogParam failed\n");
flush_sequence();
SetForegroundWindow(hother);
flush_sequence();
hactive = GetForegroundWindow();
ok(hactive == hother, "Wrong foreground (%p != %p)\n", hactive, hother);
hactive = GetActiveWindow();
ok(hactive == hother, "Wrong active window (%p != %p)\n", hactive, hother);
EndDialog(hdlg, 0);
ok(IsWindowEnabled(hparent), "parent is not enabled\n");
hactive = GetForegroundWindow();
ok(hother == hactive, "Wrong window has focus (other != active) (active: %p, parent: %p, dlg: %p, other: %p)\n", hactive, hparent, hdlg, hother);
DestroyWindow(hdlg);
flush_sequence();
DestroyWindow( hother ); DestroyWindow( hother );
DestroyWindow( hparent ); DestroyWindow( hparent );
UnregisterClassA(cls.lpszClassName, cls.hInstance); UnregisterClassA(cls.lpszClassName, cls.hInstance);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment