[PATCH] Fix EndDialog behaviour for OrCad.

Eliot Blennerhassett eblennerhassett at audioscience.com
Thu Jul 8 18:15:30 CDT 2010


While allowing existing tests to pass.
For bug#3023

Signed-off-by: Eliot Blennerhassett <eblennerhassett at audioscience.com>
---
 dlls/user32/dialog.c |   37 ++++++++++++++++++++++++++++++++-----
 1 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index aac8a4d..07174d3 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -897,6 +897,28 @@ INT_PTR WINAPI DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW temp
     return DialogBoxIndirectParamAorW( hInstance, template, owner, dlgProc, param, 0 );
 }
 
+
+/***********************************************************************
+ *           
+ *  ?Exact copy of static DEFDLG_GetDlgProc
+ *  Is there another way to do this "correctly"?
+ */
+static DLGPROC DIALOG_GetDlgProc( HWND hwnd )
+{
+    DLGPROC ret;
+    WND *wndPtr = WIN_GetPtr( hwnd );
+
+    if (!wndPtr) return 0;
+    if (wndPtr == WND_OTHER_PROCESS)
+    {
+        ERR( "cannot get dlg proc %p from other process\n", hwnd );
+        return 0;
+    }
+    ret = *(DLGPROC *)((char *)wndPtr->wExtra + DWLP_DLGPROC);
+    WIN_ReleasePtr( wndPtr );
+    return ret;
+}
+
 /***********************************************************************
  *		EndDialog (USER32.@)
  */
@@ -905,6 +927,7 @@ BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval )
     BOOL wasEnabled = TRUE;
     DIALOGINFO * dlgInfo;
     HWND owner;
+    DLGPROC dlgproc;
 
     TRACE("%p %ld\n", hwnd, retval );
 
@@ -930,8 +953,12 @@ BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval )
 
     SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE
                  | SWP_NOZORDER | SWP_NOACTIVATE | SWP_HIDEWINDOW);
-
-    if (hwnd == GetActiveWindow()) WINPOS_ActivateOtherWindow( hwnd );
+    /* Only call WINPOS_ActivateOtherWindow if hwnd is a 'dialog'
+       that doesn't have a dialog proc.
+     */
+    if (!(dlgproc = DIALOG_GetDlgProc(hwnd)))
+	if (hwnd == GetActiveWindow())
+		WINPOS_ActivateOtherWindow(hwnd);
 
     /* unblock dialog loop */
     PostMessageA(hwnd, WM_NULL, 0, 0);
@@ -1094,7 +1121,7 @@ static void DIALOG_FixChildrenOnChangeFocus (HWND hwndDlg, HWND hwndNext)
             {
                 INT dlgcode_def = SendMessageW (hwndDef, WM_GETDLGCODE, 0, 0);
                 /* I know that if it is a button then it should already be a
-                 * UNDEFPUSHBUTTON, since we have just told the buttons to 
+                 * UNDEFPUSHBUTTON, since we have just told the buttons to
                  * change style.  But maybe they ignored our request
                  */
                 if ((dlgcode_def & DLGC_BUTTON) &&
@@ -1216,7 +1243,7 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
                 if ((GetFocus() == msg->hwnd) &&
                     (SendMessageW (msg->hwnd, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON))
                 {
-                    SendMessageW (hwndDlg, WM_COMMAND, MAKEWPARAM (GetDlgCtrlID(msg->hwnd),BN_CLICKED), (LPARAM)msg->hwnd); 
+                    SendMessageW (hwndDlg, WM_COMMAND, MAKEWPARAM (GetDlgCtrlID(msg->hwnd),BN_CLICKED), (LPARAM)msg->hwnd);
                 }
                 else if (DC_HASDEFID == HIWORD(dw = SendMessageW (hwndDlg, DM_GETDEFID, 0, 0)))
                 {
@@ -1541,7 +1568,7 @@ HWND WINAPI GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
         }
     }
 
-    /* Always go forward around the group and list of controls; for the 
+    /* Always go forward around the group and list of controls; for the
      * previous control keep track; for the next break when you find one
      */
     retvalue = hwndCtrl;
-- 
1.7.0.4




More information about the wine-patches mailing list