If an MDI child becomes active restore previously maximized MDI child

Dmitry Timoshkov dmitry at baikal.ru
Tue Mar 22 07:17:28 CST 2005


Hello,

I believe that this is a more correct solution for the problem described
below. At least my test cases and a misbehaving app are now happy.

The app I'm working on creates a maximized MDI child. Then creates another
not yet visible MDI child, and does ShowWindow(SW_SHOW) on it. The state of
the 1st MDI child remains maximized, but the 2nd MDI child becomes an active
one. If I click on the 1st MDI child the app simply crashes.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    If an MDI child becomes active restore previously maximized MDI child.

--- cvs/hq/wine/windows/mdi.c	2005-03-05 23:26:30.000000000 +0800
+++ wine/windows/mdi.c	2005-03-22 21:08:41.000000000 +0800
@@ -482,7 +482,7 @@ static void MDI_ChildGetMinMaxInfo( HWND
  * Note: SetWindowPos sends WM_CHILDACTIVATE to the child window that is
  *       being activated
  */
-static void MDI_SwitchActiveChild( MDICLIENTINFO *ci, HWND hwndTo )
+static void MDI_SwitchActiveChild( MDICLIENTINFO *ci, HWND hwndTo, BOOL activate )
 {
     HWND hwndPrev;
 
@@ -507,7 +507,7 @@ static void MDI_SwitchActiveChild( MDICL
             ShowWindow( hwndTo, SW_MAXIMIZE );
         }
         /* activate new MDI child */
-        SetWindowPos( hwndTo, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
+        SetWindowPos( hwndTo, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | (activate ? 0 : SWP_NOACTIVATE) );
     }
 }
 
@@ -526,7 +526,7 @@ static LRESULT MDIDestroyChild( HWND cli
     {
         HWND next = MDI_GetWindow(ci, child, TRUE, 0);
         if (next)
-            MDI_SwitchActiveChild(ci, next);
+            MDI_SwitchActiveChild(ci, next, TRUE);
         else
         {
             ShowWindow(child, SW_HIDE);
@@ -597,6 +597,7 @@ static LONG MDI_ChildActivate( HWND clie
         SendMessageW( prevActiveWnd, WM_MDIACTIVATE, (WPARAM)prevActiveWnd, (LPARAM)child);
     }
 
+    MDI_SwitchActiveChild(clientInfo, child, FALSE);
     clientInfo->hwndActiveChild = child;
 
     MDI_RefreshMenu(clientInfo);
@@ -1061,7 +1062,7 @@ static LRESULT MDIClientWndProc_common( 
 
       case WM_MDIACTIVATE:
       {
-        MDI_SwitchActiveChild( ci, (HWND)wParam );
+        MDI_SwitchActiveChild( ci, (HWND)wParam, TRUE );
         return 0;
       }
 
@@ -1122,7 +1123,7 @@ static LRESULT MDIClientWndProc_common( 
       case WM_MDINEXT: /* lParam != 0 means previous window */
       {
         HWND next = MDI_GetWindow( ci, WIN_GetFullHandle( (HWND)wParam ), !lParam, 0 );
-        MDI_SwitchActiveChild( ci, next );
+        MDI_SwitchActiveChild( ci, next, TRUE );
 	break;
       }
 
@@ -1200,7 +1201,7 @@ static LRESULT MDIClientWndProc_common( 
 
       case WM_SIZE:
         if( IsWindow(ci->hwndActiveChild) && IsZoomed(ci->hwndActiveChild) &&
-            IsWindowVisible(ci->hwndActiveChild) )
+            (GetWindowLongW(ci->hwndActiveChild, GWL_STYLE) & WS_VISIBLE) )
 	{
 	    RECT	rect;
 






More information about the wine-patches mailing list