1、要判断,也要这样判断:
If (X = 0) Or (Y = 0) Or (X = .Width) Or (Y = .Height) Then.......
2、如果鼠标移动太快,就无法正确判断。
解决方法,考虑中

解决方案 »

  1.   

    可在MouseMove中用SetCapture me.hwnd,在判断出范围后ReleaseCapture,以上为两api
      

  2.   

    Bitsoft老兄,能不能给出详细点的代码。
      

  3.   

    '设form的ScaleMode = 3'Pixel,以下代码很粗糙,但可以说明用法:Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function ReleaseCapture Lib "user32" () As Long
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If X > Me.ScaleWidth Or Y > Me.ScaleHeight Or X < 0 Or Y < 0 Then
        ReleaseCapture
        Debug.Print "out"
    Else
        SetCapture Me.hwnd
        Debug.Print "in"
    End If
    End Sub
      

  4.   

    Private Declare Function GetCursorPos Lib "user32" (lpPoint As pointapi) As Long
    Private Declare Function WindowFromPoint Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
    Private Type pointapi
        x As Long
        y As Long
    End Type
    Dim point As pointapi
    Dim hCursorWnd As LongGetCursorPos point '取得鼠标的位置
    hCursorWnd = WindowFromPoint(point.x, point.y) '取得某一位置底下的窗口hWnd
    '通过Timer事件判断鼠标所在的位置的窗口hWnd是否等于hWnd
      

  5.   

    回复人: bitsoft() (  ) 信誉:100  
    比较喜欢这个