VB怎样限制鼠标的移动范围?

来源:百度知道 编辑:UC知道 时间:2024/06/23 09:15:02
VB怎样限制鼠标的移动范围
即使窗口最小化了或被切换了,鼠标的移动范围仍然是窗口那么大范围.
回答用VB怎样隐蔽AIT+TAB也给分.注:最好的方法!

'一个Timer1
Private Declare Function ClipCursor& Lib "user32" (lpRect As RECT)
Private Declare Function ClipCursorBynum& Lib "user32" Alias "ClipCursor" (ByVal lpRect As Long)

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

Private Sub Form_Load()
Me.Show
Timer1.Interval = 50
r1.Left = Me.Left / Screen.TwipsPerPixelX
r1.Top = Me.Top / Screen.TwipsPerPixelY
r1.Right = (Me.Left + Me.Width) / Screen.TwipsPerPixelX
r1.Bottom = (Me.Top + Me.Height) / Screen.TwipsPerPixelY
ClipCursor r1
Me.Hide
End Sub

Private Sub Timer1_Timer()
ClipCursor r1
End Sub

api里面有一个函数可以的吧。。忘了名字了