Author: rolf
Date: 2007-02-19 06:27:11 -0500 (Mon, 19 Feb 2007)
New Revision: 73105

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
Log:
* Application.cs: When disabling all forms but the main form, do not
  disable any descendants of the main form (such as mdi children or
  other parented forms). Fixes #80822 on Windows.
* Form.cs: If we have a parent, set the WS_CHILD style.
* Control.cs: Update the window styles if the control whose parent has
  changed is a form (the WS_CHILD style has to be switched).

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs   
2007-02-19 11:11:21 UTC (rev 73104)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs   
2007-02-19 11:27:11 UTC (rev 73105)
@@ -567,14 +567,34 @@
                                        while (control.MoveNext()) {
                                                f = (Form)control.Current;
                                                
-                                               if (f != context.MainForm) {
-                                                       if (f.IsHandleCreated 
&& XplatUI.IsEnabled(f.Handle)) {
-                                                               #if DebugRunLoop
-                                                                       
Console.WriteLine("      Disabling form {0}", f);
-                                                               #endif
-                                                               
XplatUI.EnableWindow(f.Handle, false);
-                                                               
toplevels.Enqueue(f);
+                                               // Don't disable the main form.
+                                               if (f == context.MainForm) {
+                                                       continue;
+                                               }
+                                               
+                                               // Don't disable any children 
of the main form.
+                                               // These do not have to be MDI 
children.
+                                               Control current = f;
+                                               bool is_child_of_main = false;;
+
+                                               do {
+                                                       if (current.Parent == 
context.MainForm) {
+                                                               
is_child_of_main = true;
+                                                               break;
                                                        }
+                                                       current = 
current.Parent;
+                                               } while (current != null);
+
+                                               if (is_child_of_main)
+                                                       continue;
+                                               
+                                               // Disable the rest
+                                               if (f.IsHandleCreated && 
XplatUI.IsEnabled(f.Handle)) {
+                                                       #if DebugRunLoop
+                                                               
Console.WriteLine("      Disabling form {0}", f);
+                                                       #endif
+                                                       
XplatUI.EnableWindow(f.Handle, false);
+                                                       toplevels.Enqueue(f);
                                                }
                                        }
                                }

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-02-19 11:11:21 UTC (rev 73104)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-02-19 11:27:11 UTC (rev 73105)
@@ -1,3 +1,12 @@
+2007-02-19  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
+
+       * Application.cs: When disabling all forms but the main form, do not
+         disable any descendants of the main form (such as mdi children or
+         other parented forms). Fixes #80822 on Windows.
+       * Form.cs: If we have a parent, set the WS_CHILD style.
+       * Control.cs: Update the window styles if the control whose parent has
+         changed is a form (the WS_CHILD style has to be switched).
+
 2007-02-19  Everaldo Canuto  <[EMAIL PROTECTED]>
 
        * XplatUIStructs.cs: MsgUIState structure added.

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs       
2007-02-19 11:11:21 UTC (rev 73104)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs       
2007-02-19 11:27:11 UTC (rev 73105)
@@ -1618,9 +1618,13 @@
 
                        parent = new_parent;
 
-                       if (IsHandleCreated)
+                       if (IsHandleCreated) {
                                XplatUI.SetParent(Handle,
                                                  (new_parent == null || 
!new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
+                               if (this is Form ) {
+                                       XplatUI.SetWindowStyle (Handle, 
CreateParams);
+                               }
+                       }
 
                        OnParentChanged(EventArgs.Empty);
 

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs  
2007-02-19 11:11:21 UTC (rev 73104)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs  
2007-02-19 11:27:11 UTC (rev 73105)
@@ -1129,6 +1129,11 @@
 
                                cp.Style = (int)(WindowStyles.WS_CLIPCHILDREN | 
WindowStyles.WS_CLIPSIBLINGS);
 
+                               if (Parent != null) {
+                                       cp.Parent = Parent.Handle;
+                                       cp.Style |= (int) WindowStyles.WS_CHILD;
+                               }
+
                                if (IsMdiChild) {
                                        cp.Style |= (int)(WindowStyles.WS_CHILD 
| WindowStyles.WS_CAPTION);
                                        if (Parent != null) {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to