vb , ClipCursor 为什么单击之后失效
的有关信息介绍如下:应该是改变了窗口的RECT信息导致失效。可以进一步限制,使鼠标不能碰到窗体边界,试试如下代码:'俩commandPrivate 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 Type RECT left As Long top As Long right As Long bottom As LongEnd TypePrivate Type POINT x As Long y As LongEnd TypePrivate Sub Command1_Click() '限制鼠标 Dim client As RECT Dim upperleft As POINT GetClientRect Me.hWnd, client upperleft.x = client.left upperleft.y = client.top ClientToScreen Me.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