Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb .net form interrupt fade out if mouse returns to form

Status
Not open for further replies.

Hfnet

IS-IT--Management
Dec 31, 2003
369
0
0
GB
Hello,

I have a form that fades out on mouse leave, but what I would like to do is to stop the fade out if the mouse returns to the form before it disappears. Is that easy to achieve?

Also, the fadeout I am using is not very effective. My form has a tabcontrol covering the entire form area. I have tried setting the form1_mouseleave event and also the tabcontrol1_mouseleave event, but neither guarantees that the form will fade if I move the mouse away. 9 times out of 10 I find I have to move the mouse slowly onto the top bar of the form window to make the form fade.

My code is:

Private Sub Form1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
Dim clientPos As Point = PointToClient(Cursor.Position)
If Not ClientRectangle.Contains(clientPos) Then
Timer_Fade.Enabled = True
End If
End Sub

Private Sub Timer_Fade_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer_Fade.Tick
If Me.Opacity > 0.1 Then
Me.Opacity -= 0.1
Else
Timer_Fade.Enabled = False
End If
End Sub

Thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top