[Mono-bugs] [Bug 77357][Nor] New - Problem with Anchor Logic [PATCH]

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Jan 25 15:38:34 EST 2006

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by don at edvalson.net.


--- shadow/77357	2006-01-25 15:38:34.000000000 -0500
+++ shadow/77357.tmp.4486	2006-01-25 15:38:34.000000000 -0500
@@ -0,0 +1,85 @@
+Bug#: 77357
+Product: Mono: Class Libraries
+Version: unspecified
+OS Details: Windows XP, OSX X11
+Status: NEW   
+Priority: Normal
+Component: Windows.Forms
+AssignedTo: peter at novonyx.com                            
+ReportedBy: don at edvalson.net               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: Problem with Anchor Logic [PATCH]
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+Unanchored controls get positioned improperly when the form is resized.
+Steps to reproduce the problem:
+1. Create a form with a maximize button and a minimize button.
+2. Put a control (I used a panel) on it that fills the entire form. Make 
+sure the control is unanchored (no anchors at all.
+3. Run the app. I starts out OK.
+4. Maximize the app. The control is centered in the form as it should be.
+5. Restore the app to it's original size. The control is now partially 
+off the form. It should have stayed where it was.
+6. Minimize the app, then restore it. The control is now in a different 
+Actual Results: The control shows up all over the form.
+Expected Results: The control should stay in the same place
+How often does this happen? always
+Additional Information:
+There are actually two bugs here. The maximize bug and the minimize bug 
+are different.
+The maximize bug is caused by UpdateDistances updating the dist_left and 
+dist_top when it shouldn't. That problem seems to be fixed by changing 
+UpdateDistances to this:
+private void UpdateDistances() {
+    if ((parent != null) && (parent.layout_suspended == 0)) {
+	dist_left = bounds.X;
+	dist_top = bounds.Y;
+	dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
+	dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
+    }
+(I put the dist_left and dist_top statements inside the if)
+The minimize problem is harder. I have partially fixed by changing one of 
+the overloads of UpdateBounds as follows:
+protected void UpdateBounds(int x, int y, int width, int height, int 
+clientWidth, int clientHeight) {
+    UpdateBounds(x, y, width, height);
+    if (this.client_size.Width != clientWidth || this.client_size.Height !
+= clientHeight)
+    {
+	this.client_size.Width=clientWidth;
+	this.client_size.Height=clientHeight;
+	PerformLayout();
+    }
+(I added the if statement and the PerformLayout)
+This sort of fixes it. After coming back from a minimize, now you just 
+have to cause a repaint (obscure the form or move it) and the problem 
+goes away).

More information about the mono-bugs mailing list