[Mono-bugs] [Bug 79433][Nor] New - [Windows] Menus steal focus from form.

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Sep 17 20:47:40 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 monkey at jpobst.com.


--- shadow/79433	2006-09-17 20:47:40.000000000 -0400
+++ shadow/79433.tmp.4751	2006-09-17 20:47:40.000000000 -0400
@@ -0,0 +1,59 @@
+Bug#: 79433
+Product: Mono: Class Libraries
+Version: 1.1
+OS Details: Windows
+Status: NEW   
+Priority: Normal
+Component: Windows.Forms
+AssignedTo: toshok at ximian.com                            
+ReportedBy: monkey at jpobst.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: [Windows] Menus steal focus from form.
+Description of Problem:
+When a menu is clicked, focus moves from the form to the menu.  (The form's
+title bar dims and the form's taskbar button is deselected.) 
+Steps to reproduce the problem:
+1. Run winforms\formstest
+2. Click the file menu item.
+Actual Results:
+The form's titlebar dims (loses focus).
+Expected Results:
+The form should keep focus.
+How often does this happen? 
+Additional Information:
+Most of the solution seems like this:
+http://www.dotnet247.com/247reference/msgs/44/221214.aspx.  If I add:
+[DllImport ("user32.dll")]
+private extern static IntPtr SetActiveWindow (IntPtr handle);
+private const int WM_ACTIVATE = 6;
+private const int WA_INACTIVE = 0;
+protected override void WndProc (ref Message m)
+  if (m.Msg == WM_ACTIVATE) {
+    if (((int)m.WParam & 0xFFFF) != WA_INACTIVE) {
+      if (m.LParam != IntPtr.Zero) SetActiveWindow (m.LParam);
+    }
+  }
+  base.WndProc (ref m);
+to System.Windows.Forms.PopUpWindow (MenuAPI.cs), it fixed the focus
+problem, which is the main part.  The taskbar button is still deselected. 
+Maybe someone know how to fix that part.  I didn't submit this as a patch,
+as the code probably needs to be cleaned up, and there may be an internal
+method to call that already wraps this dll call.

More information about the mono-bugs mailing list