Просмотр исходного кода

2007-01-22 Jonathan Pobst <[email protected]>

	* Form.cs: Changing FormBorderStyle has different semantics based
	on whether the Form is visible or not.  If not visible, don't change
	the Size.  But InvalidateNC needs to be called to force the window
	to pick up the changes and redraw itself.  [Fixes bug #80574]

svn path=/trunk/mcs/; revision=71480
Jonathan Pobst 19 лет назад
Родитель
Сommit
d0b335b0c8

+ 7 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog

@@ -1,3 +1,10 @@
+2007-01-22  Jonathan Pobst  <[email protected]>
+
+	* Form.cs: Changing FormBorderStyle has different semantics based
+	on whether the Form is visible or not.  If not visible, don't change
+	the Size.  But InvalidateNC needs to be called to force the window
+	to pick up the changes and redraw itself.  [Fixes bug #80574]
+
 2007-01-22  Jonathan Pobst  <[email protected]>
 
 	[Moma work]

+ 5 - 1
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs

@@ -481,7 +481,11 @@ namespace System.Windows.Forms {
 				}
 
 				UpdateStyles();
-				this.Size = SizeFromClientSize (this.ClientSize);
+				
+				if (this.Visible) 
+					this.Size = SizeFromClientSize (this.ClientSize);
+				else
+					XplatUI.InvalidateNC (this.Handle);
 			}
 		}
 

+ 4 - 0
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog

@@ -1,3 +1,7 @@
+2007-01-18  Jonathan Pobst  <[email protected]>
+
+	* FormTest.cs: Add test for bug #80574.
+
 2007-01-22  Jonathan Pobst  <[email protected]>
 
 	* TabControlTest.cs: Add tests for SelectTab and Selected event.

+ 37 - 0
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs

@@ -623,6 +623,43 @@ namespace MonoTests.System.Windows.Forms
 			
 			f.Close ();
 		}
+		
+		[Test]	// bug #80574
+		public void BehaviorResizeOnBorderStyleChangedNotVisible ()
+		{
+			Form f = new Form ();
+
+			Assert.AreEqual (new Size (300, 300), f.Size, "A1");
+			Assert.AreEqual (new Size (292, 266), f.ClientSize, "A2");
+
+			f.FormBorderStyle = FormBorderStyle.Fixed3D;
+			Assert.AreEqual (new Size (300, 300), f.Size, "A3");
+			Assert.AreEqual (new Size (292, 266), f.ClientSize, "A4");
+
+			f.FormBorderStyle = FormBorderStyle.FixedDialog;
+			Assert.AreEqual (new Size (300, 300), f.Size, "A5");
+			Assert.AreEqual (new Size (292, 266), f.ClientSize, "A6");
+
+			f.FormBorderStyle = FormBorderStyle.FixedSingle;
+			Assert.AreEqual (new Size (300, 300), f.Size, "A7");
+			Assert.AreEqual (new Size (292, 266), f.ClientSize, "A8");
+
+			f.FormBorderStyle = FormBorderStyle.FixedToolWindow;
+			Assert.AreEqual (new Size (300, 300), f.Size, "A9");
+			Assert.AreEqual (new Size (292, 266), f.ClientSize, "A0");
+
+			f.FormBorderStyle = FormBorderStyle.None;
+			Assert.AreEqual (new Size (300, 300), f.Size, "A11");
+			Assert.AreEqual (new Size (292, 266), f.ClientSize, "A12");
+
+			f.FormBorderStyle = FormBorderStyle.SizableToolWindow;
+			Assert.AreEqual (new Size (300, 300), f.Size, "A13");
+			Assert.AreEqual (new Size (292, 266), f.ClientSize, "A14");
+
+			f.FormBorderStyle = FormBorderStyle.Sizable;
+			Assert.AreEqual (new Size (300, 300), f.Size, "A15");
+			Assert.AreEqual (new Size (292, 266), f.ClientSize, "A16");
+		}
 #endif
 
 		private bool RunningOnUnix {