In a simple two form project, use a button on each form to Show() the other
form and Hide() the current form. Add MouseEnter and MouseLeave events to
both buttons so they change the image on each button when they are NOT
Clicked but the cursor enters their boundary.
This setup works fine. If the mouse cursor enters the button on the first
form the image changes and if the button is clicked the first form
disappears and the other form duly appears. When the mouse cursor enters the
second form button the image changes and if the second form button is
clicked the second form disappears and the first form reappears with a
button showing the "Normal" (As Opposed to "Hover" Image). Repeat and
everything works fine. Now if you spread the images apart you see that they
are both present all the time, it is the focus that is really changing.
This can be repeated with Visible = True or False instead of Show() and
Hide()
Now create a new project. Repeat the above but where a third form, the first
one created is an mdi Parent and the two forms Form2 and Form3 are children.
Now the button image works fine until you click it. Now the second form
(Form3) appears and it's button works fine until you click it. Upon
returning to the first form (Form2) the image is locked at the hover image
and does not change. Returning to the second form (Form3) you will find it's
button's image is also locked.
Note that in this instance the forms do actually disappear from view.
Why does this happen and how do you cure it?
If you have forms with several hover buttons present the effects can be
random and have an effect on some or ALL buttons even when they were not
used.
Event handlers do not seem to work unless I've developed a blind spot from
staring at the problem for too long. Also the useful advice from the MS Help
page : "Handling User Input"
Under : Mouse events
Event Name : Mouse Enter
Method to Override : void OnMouseEnter (EventArgs)
Or
Event Name : Mouse Leave
Method to Override : void OnMouseLeave (EventArgs)
Seems less than helpful
Any cures anyone ?