VB 锁定鼠标(0,0)

可用的,感谢... 可用的,感谢 展开
 我来答
AeroDOS
2009-06-03 · TA获得超过2642个赞
知道小有建树答主
回答量:815
采纳率:0%
帮助的人:626万
展开全部
如果不把代码timer中的话,按下徽标键加D的话可以简单地取消区域限制。
Option Explicit
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private 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 Long

Private Sub Form_DblClick()
End
End Sub

Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 500
End Sub

Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
End Sub
'限制鼠标在当前窗体的区域,而且使当前的窗体始终在最最前面
Private Sub Timer1_Timer()
Dim ding As RECT
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3
GetWindowRect Me.hwnd, ding
ClipCursor ding
End Sub

'限制鼠标在当前窗体的某个点上,这时可以把Timer1.Interval改小点。
Private Sub Timer1_Timer()
Dim m As Long, n As Long
m = 500
n = 500
SetCursorPos m, n
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3
End Sub

参考资料: http://zhidao.baidu.com/question/37233128.html

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式