当前位置:百问家>百科问答>vb , ClipCursor 为什么单击之后失效

vb , ClipCursor 为什么单击之后失效

2024-09-14 22:19:40 编辑:zane 浏览量:538

vb , ClipCursor 为什么单击之后失效

的有关信息介绍如下:

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

版权声明:文章由 百问家 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.baiwenjia.com/answer/158315.html
热门文章