vb将鼠标锁定在一个窗口范围内

来源:百度知道 编辑:UC知道 时间:2024/06/09 00:27:28
搜索获得一个指定的窗口,然后将鼠标锁定在窗口的范围内。

'画两个按钮,使用如下代码
Option Explicit

Private Type RECT
left As Long
top As Long
right As Long
bottom As Long
End Type
Private Type POINT
x As Long
y As Long
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Sub ClipCursor Lib "user32" (lpRect As Any)
Private Declare Sub GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT)
Private Declare Sub ClientToScreen Lib "user32" (ByVal hWnd As Long, lpPoint As POINT)
Private Declare Sub OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long)
Private Sub Form_Load()
Command1.Caption = "限制"
Command2.Caption = "解除"
End Sub
Private Sub Command1_Click()
Dim client As RECT
Di