Jacek Caban : user32: Always enable owner window in EndDialog.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Feb 26 10:26:46 CST 2016


Module: wine
Branch: master
Commit: 142133ae6c973a06e90b6de32c55fae757372a43
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=142133ae6c973a06e90b6de32c55fae757372a43

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Feb 25 17:32:54 2016 +0100

user32: Always enable owner window in EndDialog.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/dialog.c    |  8 ++------
 dlls/user32/tests/msg.c | 28 ++++++++++++++++++++++++----
 2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index e841152..f3c8289 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -921,7 +921,6 @@ INT_PTR WINAPI DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW temp
  */
 BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval )
 {
-    BOOL wasEnabled;
     DIALOGINFO * dlgInfo;
     HWND owner;
 
@@ -934,10 +933,9 @@ BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval )
     }
     dlgInfo->idResult = retval;
     dlgInfo->flags |= DF_END;
-    wasEnabled = (dlgInfo->flags & DF_OWNERENABLED);
 
     owner = GetWindow( hwnd, GW_OWNER );
-    if (wasEnabled && owner)
+    if (owner)
         DIALOG_EnableOwner( owner );
 
     /* Windows sets the focus to the dialog itself in EndDialog */
@@ -953,9 +951,7 @@ BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval )
 
     if (hwnd == GetActiveWindow())
     {
-        /* 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 this dialog was given an owner then set the focus to that owner. */
         if (owner)
             SetForegroundWindow( owner );
         else
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 98bf53d..cc92acf 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -12226,7 +12226,7 @@ static void test_EndDialog(void)
 
     hother = CreateWindowExA(0, "TestParentClass", "Test parent 2",
                               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(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
@@ -12240,20 +12240,40 @@ static void test_EndDialog(void)
     hactive = GetForegroundWindow();
     ok(hother == hactive, "Wrong window has focus (%p != %p)\n", hother, hactive);
 
-    /* create a dialog where the parent is disabled, this parent should still
-       receive the focus when the dialog exits (even though "normally" a
-       disabled window should not receive the focus) */
+    /* create a dialog where the parent is disabled, this parent should be
+     * enabled and receive focus when dialog exits */
     hdlg = CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", hparent, test_dlg_proc, 0);
     ok(IsWindow(hdlg), "CreateDialogParam failed\n");
     SetForegroundWindow(hdlg);
     hactive = GetForegroundWindow();
     ok(hdlg == hactive, "Wrong window has focus (%p != %p)\n", hdlg, hactive);
     EndDialog(hdlg, 0);
+    ok(IsWindowEnabled(hparent), "parent is not enabled\n");
     hactive = GetForegroundWindow();
     ok(hparent == hactive, "Wrong window has focus (parent != active) (active: %p, parent: %p, dlg: %p, other: %p)\n", hactive, hparent, hdlg, hother);
     DestroyWindow(hdlg);
     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( hparent );
     UnregisterClassA(cls.lpszClassName, cls.hInstance);




More information about the wine-cvs mailing list