[Mono-bugs] [Bug 78486][Min] Changed - [PATCH] ContainerControl should not receive focus

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Jun 14 03:16:03 EDT 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 atsushi at ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=78486

--- shadow/78486	2006-06-14 03:09:20.000000000 -0400
+++ shadow/78486.tmp.31557	2006-06-14 03:16:02.000000000 -0400
@@ -1,23 +1,23 @@
 Bug#: 78486
 Product: Mono: Class Libraries
 Version: 1.1
-OS: 
+OS: unknown
 OS Details: 
 Status: NEW   
 Resolution: 
-Severity: 
+Severity: Unknown
 Priority: Minor
 Component: Windows.Forms
 AssignedTo: peter at novonyx.com                            
 ReportedBy: atsushi at ximian.com               
 QAContact: mono-bugs at ximian.com
 TargetMilestone: ---
 URL: 
 Cc: 
-Summary: ContainerControl should not receive focus
+Summary: [PATCH] ContainerControl should not receive focus
 
 The following example demonstrates that either UserControl or Form steals a
 focus from its child Button:
 
 using System;
 using System.Drawing;
@@ -66,6 +66,60 @@
 this problem does not happen.
 
 ------- Additional Comments From atsushi at ximian.com  2006-06-14 03:09 -------
 Created an attachment (id=17176)
 proposed fix
 
+
+------- Additional Comments From atsushi at ximian.com  2006-06-14 03:15 -------
+At first I doubted that such conditioning to pass control focus is
+done by WS_EX_CONTROLPARENT, but it does not look so:
+
+--------
+using System;
+using System.Windows.Forms;
+
+public class Test : Form
+{
+	public static void Main ()
+	{
+		Application.Run (new Test ());
+	}
+
+	public Test ()
+	{
+		MyContainerControl c = new MyContainerControl ();
+		Controls.Add (c);
+		Controls.Add (new MyButton ());
+		Console.WriteLine (c.Params);
+		Visible = true;
+		Console.WriteLine ("{0} {1}", c.CanFocus, c.CanSelect);
+		c.Controls.Add (new Button ());
+		Console.WriteLine ("{0} {1}", c.CanFocus, c.CanSelect);
+	}
+}
+
+public class MyContainerControl : ContainerControl
+{
+	public CreateParams Params {
+		get { return CreateParams; }
+	}
+}
+
+public class MyButton : Button
+{
+	// This verifies that WS_EX_CONTROLPARENT does not immediately means
+	// that it does not receive focus.
+	protected override CreateParams CreateParams {
+		get { 
+			CreateParams basis = base.CreateParams;
+			basis.ExStyle |= 0x10000; // WS_EX_CONTROLPARENT
+			return basis;
+		}
+	}
+}
+--------
+
+MyButton receives focus as usual (while it has WS_EX_CONTROLPARENT).
+So I think only ContainerControl class matters. Conditioning by
+WS_EX_CONTROLPARENT (changing ContainerControl.CreateParams) is wrong
+since such changes make MyButton not focusible.


More information about the mono-bugs mailing list