您的位置首页百科知识

鼠标锁定

鼠标锁定

的有关信息介绍如下:

鼠标锁定

'画两个按钮,使用如下代码Option ExplicitPrivate Type RECT left As Long top As Long right As Long bottom As LongEnd TypePrivate Type POINT x As Long y As LongEnd TypePrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate 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 SubPrivate Sub Command1_Click() Dim client As RECT Dim upperleft As POINT Dim hWnd As Long '查找标题为“form1”的窗口 hWnd = FindWindow(vbNullString, "Form1") GetClientRect hWnd, client upperleft.x = client.left upperleft.y = client.top ClientToScreen hWnd, upperleft OffsetRect client, upperleft.x, upperleft.y ClipCursor clientEnd SubPrivate Sub Command2_Click() ClipCursor ByVal 0&End SubPrivate Sub Form_Unload(Cancel As Integer) ClipCursor ByVal 0&End Sub