求vb锁定鼠标代码!

来源:百度知道 编辑:UC知道 时间:2024/05/31 14:29:34
要高手原创的,网上那种我试过,不成!简洁点最好!

如果不把代码timer中的话,按下徽标键加D的话可以简单地取消区域限制。
Option Explicit
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Sub Form_DblClick()
End
End Sub

Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 500
End Sub

Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
End Sub
'限制鼠标在当前