vb 锁定鼠标到某一位置

Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

 

Private Sub Command1_Click() '锁定鼠标 到某一位置
    Dim r As RECT
    r.Left = 100: r.Top = 100
    r.Right = 100: r.Bottom = 100
    ClipCursor r
End Sub

 

Private Sub Command2_Click() '解除锁定
    ClipCursor ByVal 0&
End Sub

'原帖地址:

http://fy5388.blog.163.com/blog/static/5649953720091127115554104/

你可能感兴趣的:(vb 锁定鼠标到某一位置)