postmessage 能不能模拟发送鼠标移动的消息?
不是要改变鼠标的位置,只是想给一个按钮发送鼠标经过的消息,不知道能不能实现

解决方案 »

  1.   

    就是比如一个按钮,鼠标移上去后,和鼠标没移上去显示出来的有区别,我现在不想通过SETCURSORPOS来移动鼠标,只想发送个鼠标移动过去的消息,不知道能不能实现
      

  2.   


    Option ExplicitPrivate Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
    Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
       If Button = 0 Then
            If (X < 0) Or (Y < 0) Or (X > Command1.Width) Or (Y > Command1.Height) Then
                ReleaseCapture
                ' 放入鼠标离开的代码
                Command1.Caption = "鼠标离开"
            Else
                SetCapture Command1.hWnd
                ' 放入鼠标进入的代码
                Command1.Caption = "鼠标进入"
            End If
        End If
    End Sub
      

  3.   

    我看你还是使用SetCursorPos来设置鼠标的位置为最佳方法。