现在的位置: 首页 > 综合 > 正文

捕获按钮离开事件.Simulate MouseEnter and MouseLeave events

2012年03月10日 ⁄ 综合 ⁄ 共 519字 ⁄ 字号 评论关闭
Option Explicit

Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCapture Lib "user32" () As Long

Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   
    With Command1
        If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then 'MouseLeave
            Call ReleaseCapture
        ElseIf GetCapture() <> .hwnd Then 'MouseEnter
            Call SetCapture(.hwnd)
        Else
            'Normal MouseMove
        End If
    End With

End Sub

抱歉!评论已关闭.