How to detect when the mouse leaves the form?

前端 未结 4 759
南笙
南笙 2020-12-11 21:23

I have a form with a lot of controls on it. How can I detect when the mouse leaves the form? I\'ve tried wiring up a MouseLeave event for every single control and the form

4条回答
  •  既然无缘
    2020-12-11 22:13

    Put this in timer:

    If PointToClient(MousePosition).X < Me.Size.Width AndAlso PointToClient(MousePosition).X > -1 AndAlso PointToClient(MousePosition).Y < Me.Size.Height AndAlso PointToClient(MousePosition).Y > -1 Then
        'Mouse is inside the form
    Else
        'Mouse is outside of form
    End If
    

提交回复
热议问题