User Controls no longer fire OnMouseLeave when parent form's parent is changed


B

B Loggins

I have seen some vague references to this problem before, but no
answers so here are the exact steps to reproduce:

(Visual Studio.NET 2003)

1) Create a new Windows Project
2) For your main form, set IsMdiContainer to true
3) Create a new Form class
4) Create a new UserControl class
5) In the UserControl class, override OnMouseLeave, put
Console.WriteLine("Control MouseLeave") ; in it
6) Drop the user control onto the new form
7) In the MdiParent's load, create two of these new forms, add them to
some collection to keep track of them, and set the MdiParent of the two
forms to the Mdi parent
8) Add a button to the Mdi parent
9) In the button event handler, loop through the forms created,
alternating between setting MdiParent to the Mdi form or null (that way
each time the button is pressed, the forms go from being top level to
mdi children)

10) Run the app. Notice that as you move your mouse over and out of
the user controls on the forms, you get "Control MouseLeave" messages.

11) Hit the button to toggle the windows. Now notice that you no
longer get "Control MouseLeave" messages on at least one of the forms.

It seems that setting the MdiParent property of the form disables
OnMouseLeave events for controls on that form. I've tried looking for
information on this bug but to no avail. Any pointers? Thanks.
 
Ad

Advertisements

B

B Loggins

OK. How about this: what is the preferred way of having an app that
switches between MDI and SDI modes in .NET?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top