Author: jpobst
Date: 2007-03-27 11:16:10 -0500 (Tue, 27 Mar 2007)
New Revision: 75026

Modified:
   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
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
Log:
2007-03-27  Jonathan Pobst  <[EMAIL PROTECTED]>

        * Control.cs: We won't get a WM_SHOWWINDOW when we create a window that
        is maximized or minimized, so move CreateControl to 
Control.OnVisibleChanged.
        * Form.cs: After we set the form visible, send a fake WM_SHOWWINDOW if 
we
        are max or min.  Remove WS_VISIBLE from CreateParams unless we are 
recreating
        the handle.  Fix WindowState by using the internal variable until we 
are 
        sure that we've been shown.
        * XplatUIX11.cs: Do not generate a WM_SHOWWINDOW message if new form is
        max or min.
        [Fixes bug #81198]

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-03-27 15:51:33 UTC (rev 75025)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-03-27 16:16:10 UTC (rev 75026)
@@ -1,3 +1,15 @@
+2007-03-27  Jonathan Pobst  <[EMAIL PROTECTED]>
+
+       * Control.cs: We won't get a WM_SHOWWINDOW when we create a window that
+       is maximized or minimized, so move CreateControl to 
Control.OnVisibleChanged.
+       * Form.cs: After we set the form visible, send a fake WM_SHOWWINDOW if 
we
+       are max or min.  Remove WS_VISIBLE from CreateParams unless we are 
recreating
+       the handle.  Fix WindowState by using the internal variable until we 
are 
+       sure that we've been shown.
+       * XplatUIX11.cs: Do not generate a WM_SHOWWINDOW message if new form is
+       max or min.
+       [Fixes bug #81198]
+
 2007-03-27  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
 
        * XplatUIX11.cs: Windows without WS_CAPTION can still get decorations

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs       
2007-03-27 15:51:33 UTC (rev 75025)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs       
2007-03-27 16:16:10 UTC (rev 75026)
@@ -4295,11 +4295,18 @@
                                }
 
                                if (IsHandleCreated) {
-                                       XplatUI.SetVisible(Handle, is_visible, 
true);
-                                       // Explicitly move Toplevel windows to 
where we want them;
-                                       // apparently moving unmapped toplevel 
windows doesn't work
-                                       if (is_visible && (this is Form)) {
-                                               
XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, 
bounds.Height);
+                                       XplatUI.SetVisible (Handle, is_visible, 
true);
+                                       
+                                       if (is_visible && this is Form) {
+                                               // If we are Min or Max, we 
won't get a WM_SHOWWINDOW from SetWindowState,
+                                               // so we need to manually 
create our children, and set them visible
+                                               // (This normally happens in 
WmShowWindow.)
+                                               if ((this as Form).WindowState 
!= FormWindowState.Normal)
+                                                       OnVisibleChanged 
(EventArgs.Empty);
+                                               else
+                                                       // Explicitly move 
Toplevel windows to where we want them;
+                                                       // apparently moving 
unmapped toplevel windows doesn't work
+                                                       
XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, 
bounds.Height);   
                                        }
                                }
                                else {
@@ -4915,13 +4922,14 @@
 
                private void WmShowWindow (ref Message m) {
                        if (m.WParam.ToInt32() != 0) {
-                               CreateControl ();
-                               /* if we're being shown, make sure our child 
controls all have their handles created */
-                               Control [] controls = 
child_controls.GetAllControls ();
-                               for (int i=0; i<controls.Length; i++) {
-                                       if (controls [i].is_visible) {
-                                               controls [i].CreateControl ();
-                                               
XplatUI.SetParent(controls[i].Handle, window.Handle); 
+                               if (m.LParam.ToInt32 () == 0) {
+                                       CreateControl ();
+                               
+                                       // Make sure all our children are 
properly parented to us
+                                       Control [] controls = 
child_controls.GetAllControls ();
+                                       for (int i=0; i<controls.Length; i++) {
+                                               if (controls [i].is_visible && 
controls[i].IsHandleCreated)                                             
+                                                       
XplatUI.SetParent(controls[i].Handle, window.Handle); 
                                        }
                                }
                        }
@@ -4937,7 +4945,13 @@
                                }
                        }
 
-                       if (is_toplevel || (this is Form && ((Form) 
this).IsMdiChild)) /* XXX make sure this works for mdi forms */
+                       // If the form is Max/Min, it got its OnVisibleChanged 
in SetVisibleCore
+                       if (this is Form) {
+                               Form f = (Form)this;
+                               
+                               if (f.IsMdiChild || f.WindowState == 
FormWindowState.Normal) /* XXX make sure this works for mdi forms */
+                                       OnVisibleChanged(EventArgs.Empty);
+                       } else if (is_toplevel)
                                OnVisibleChanged(EventArgs.Empty);
                }
 
@@ -5633,6 +5647,9 @@
 
                [EditorBrowsable(EditorBrowsableState.Advanced)]
                protected virtual void OnVisibleChanged(EventArgs e) {
+                       if (Visible)
+                               CreateControl ();
+                               
                        EventHandler eh = (EventHandler)(Events 
[VisibleChangedEvent]);
                        if (eh != null)
                                eh (this, e);

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs  
2007-03-27 15:51:33 UTC (rev 75025)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs  
2007-03-27 16:16:10 UTC (rev 75026)
@@ -87,11 +87,11 @@
                private bool                    is_loaded;
                internal bool                   is_changing_visible_state;
                internal bool                   has_been_visible;
+               private bool                    shown_raised;  // The shown 
event is only raised once
 
 #if NET_2_0
                private MenuStrip               main_menu_strip;
                private bool                    show_icon = true;
-               private bool                    shown_raised;  // The shown 
event is only raised once
 #endif
                #endregion      // Local Variables
 
@@ -1076,7 +1076,8 @@
                [MWFCategory("Layout")]
                public FormWindowState WindowState {
                        get {
-                               if (IsHandleCreated) {
+                               // Don't actually rely on the WM until we've 
been shown
+                               if (IsHandleCreated && shown_raised) {
 
                                        if (window_manager != null)
                                                return 
window_manager.GetWindowState ();
@@ -1092,7 +1093,7 @@
                        set {
                                FormWindowState old_state = window_state;
                                window_state = value;
-                               if (IsHandleCreated) {
+                               if (IsHandleCreated && shown_raised) {
 
                                        if (window_manager != null) {
                                                window_manager.SetWindowState 
(old_state, value);
@@ -1261,8 +1262,8 @@
                                if (HelpButton && !MaximizeBox && !MinimizeBox) 
{
                                        cp.ExStyle |= 
(int)WindowExStyles.WS_EX_CONTEXTHELP;
                                }
-                               
-                               if (VisibleInternal)
+
+                               if (VisibleInternal && this.IsRecreating)
                                        cp.Style |= 
(int)WindowStyles.WS_VISIBLE;
 
                                if (opacity < 1.0 || TransparencyKey != 
Color.Empty) {
@@ -2063,6 +2064,10 @@
                                is_changing_visible_state = true;
                                has_been_visible = value || has_been_visible;
                                base.SetVisibleCore (value);
+                               
+                               if (value && WindowState != 
FormWindowState.Normal)
+                                       XplatUI.SendMessage (Handle, 
Msg.WM_SHOWWINDOW, (IntPtr)1, IntPtr.Zero);
+                                       
                                is_changing_visible_state = false;
                        }
                        
@@ -2082,13 +2087,14 @@
                                PerformLayout ();
                                
ThemeEngine.Current.ManagedWindowSetButtonLocations (window_manager);
                        }
-#if NET_2_0
+                       
                        // Shown event is only called once, the first time the 
form is made visible
                        if (value && !shown_raised) {
+#if NET_2_0
                                this.OnShown (EventArgs.Empty);
+#endif
                                shown_raised = true;
                        }
-#endif
                }
 
                protected override void UpdateDefaultButton() {

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs    
2007-03-27 15:51:33 UTC (rev 75025)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs    
2007-03-27 16:16:10 UTC (rev 75026)
@@ -1308,8 +1308,11 @@
 
                private void MapWindow(Hwnd hwnd, WindowType windows) {
                        if (!hwnd.mapped) {
-                               if (Control.FromHandle(hwnd.Handle) is Form)
-                                       SendMessage(hwnd.Handle, 
Msg.WM_SHOWWINDOW, (IntPtr)1, IntPtr.Zero);
+                               if (Control.FromHandle(hwnd.Handle) is Form) {
+                                       Form f = 
Control.FromHandle(hwnd.Handle) as Form;
+                                       if (f.WindowState == 
FormWindowState.Normal)
+                                               SendMessage(hwnd.Handle, 
Msg.WM_SHOWWINDOW, (IntPtr)1, IntPtr.Zero);
+                               }
 
                                // it's possible that our Hwnd is no
                                // longer valid after making that
@@ -1337,8 +1340,11 @@
 
                private void UnmapWindow(Hwnd hwnd, WindowType windows) {
                        if (hwnd.mapped) {
-                               if (Control.FromHandle(hwnd.Handle) is Form)
+                               if (Control.FromHandle(hwnd.Handle) is Form) {
+                                       Form f = 
Control.FromHandle(hwnd.Handle) as Form;
+                                       if (f.WindowState == 
FormWindowState.Normal)
                                        SendMessage(hwnd.Handle, 
Msg.WM_SHOWWINDOW, IntPtr.Zero, IntPtr.Zero);
+                               }
 
                                // it's possible that our Hwnd is no
                                // longer valid after making that

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

Reply via email to