[Mono-bugs] [Bug 73606][Maj] New - OnCreateControl() called when ClientSize changed, and called more than once
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Fri, 11 Mar 2005 13:50:35 -0500 (EST)
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 4lw0e0402@sneakemail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=73606
--- shadow/73606 2005-03-11 13:50:34.000000000 -0500
+++ shadow/73606.tmp.1749 2005-03-11 13:50:35.000000000 -0500
@@ -0,0 +1,106 @@
+Bug#: 73606
+Product: Mono: Class Libraries
+Version: unspecified
+OS: other
+OS Details: platforms using the XplatUIX11 driver
+Status: NEW
+Resolution:
+Severity:
+Priority: Major
+Component: Windows.Forms
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: 4lw0e0402@sneakemail.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: OnCreateControl() called when ClientSize changed, and called more than once
+
+Description of Problem:
+ With Microsoft's S.W.F implementation, adjusting a control's ClientSize
+ before it has been realized does not realize the control. With the
+ current mono implementation, Control::SetClientSizeCore () always reads
+ the Control::Handle property, which realizes the control and calls
+ CreateControl ().
+
+ In addition, with Microsoft's implementation, OnCreateControl () is only
+ ever called once, regardless of how many times CreateControl () is
+ called. With mono's implementation, OnCreateControl () is called twice
+ the first time CreateControl () is called and once more for each
+ additional call.
+
+Steps to reproduce the problem:
+1. Create a subclass of Control with some debug output code in an override
+of the OnCreateControl () method.
+2. In that Control's constructor, adjust ClientSize between two other
+debug output calls.
+3. Insert several calls to CreateControl () in the control.
+4. Create an instance of the control.
+
+class TestControl : System.Windows.Forms.Control
+{
+ public TestControl (bool call_create_control)
+ {
+ if (call_create_control)
+ CreateControl();
+
+ System.Console.WriteLine (" Before assignment to ClientSize");
+ ClientSize = new System.Drawing.Size(500, 300);
+ System.Console.WriteLine (" After assignment to ClientSize");
+ }
+
+ protected override void OnCreateControl ()
+ {
+ System.Console.WriteLine (" OnCreateControl () called");
+ }
+
+ static void Main ()
+ {
+ System.Console.WriteLine ("First object:");
+ new TestControl (false).CreateControl ();
+ System.Console.WriteLine ("Second object:");
+ new TestControl (true).CreateControl ();
+ }
+}
+
+Actual Results:
+ With the above test code, the Microsoft runtime's output is:
+
+First object:
+ Before assignment to ClientSize
+ After assignment to ClientSize
+ OnCreateControl () called
+Second object:
+ OnCreateControl () called
+ Before assignment to ClientSize
+ After assignment to ClientSize
+
+With mono svn, the output is:
+
+First object:
+Mono System.Windows.Forms Assembly [Revision: 41586; built: 2005/2/9
+1:7:30]
+Keyboard: United States keyboard layout (phantom key version)
+ Before assignment to ClientSize
+ OnCreateControl () called
+ After assignment to ClientSize
+ OnCreateControl () called
+Second object:
+ OnCreateControl () called
+ OnCreateControl () called
+ Before assignment to ClientSize
+ After assignment to ClientSize
+ OnCreateControl () called
+
+Expected Results:
+ Mono should follow the Microsoft runtime's behaviour.
+
+Additional Information:
+ The attached Control.cs implements an alternate solution to bug #73190.
+ With it installed, the mono runtime's output is identical to Microsoft's.
+ It takes a different approach: Instead of trying to avoid spurious
+ calls to Control::CreateControl (), it ensures that it only calls
+ Control::OnCreateControl () once from Control::CreateControl (). The
+ existing SVN fix to bug #73190 has Control::CreateHandle () call
+ Control::CreateControl (); the attached Control.cs reverses this,
+ replacing a number of calls to CreateHandle () to CreateControl ().