当前位置:百问九>百科知识>求vb锁定鼠标代码!

求vb锁定鼠标代码!

2023-05-09 16:17:13 编辑:zane 浏览量:602

求vb锁定鼠标代码!

如果不把代码timer中举罩做的话,按下徽标正衡键加D的话可以简单地取消区域限制。Option ExplicitPrivate Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As LongPrivate Declare Function ClipCursor Lib "user32" (lpRect As Any) As LongPrivate Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As LongPrivate Type RECT Left As Long Top As Long Right As Long Bottom As LongEnd TypePrivate 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 LongPrivate Sub Form_DblClick()EndEnd SubPrivate Sub Form_Load()Timer1.Enabled = TrueTimer1.Interval = 500End SubPrivate Sub Form_Unload(Cancel As Integer)Cancel = 1End Sub'限制鼠标在当前闷旦窗体的区域,而且使当前的窗体始终在最最前面Private Sub Timer1_Timer()Dim ding As RECTSetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3GetWindowRect Me.hwnd, dingClipCursor dingEnd Sub'限制鼠标在当前窗体的某个点上,这时可以把Timer1.Interval改小点。Private Sub Timer1_Timer()Dim m As Long, n As Longm = 500n = 500SetCursorPos m, nSetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3End Sub

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