VB 中怎样把鼠标限制在窗体范围内?

VB中怎样把鼠标限制在窗体范围内?... VB 中怎样把鼠标限制在窗体范围内? 展开
 我来答
帐号已注销
2007-04-21 · TA获得超过197个赞
知道小有建树答主
回答量:218
采纳率:0%
帮助的人:283万
展开全部
Option Explicit
Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Private Declare Function ClipCursorBynum& Lib "user32" Alias "ClipCursor" (ByVal lpRect As Long)
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim mouse As RECT
Private Sub Command1_Click()

mouse.Left = Me.Left / Screen.TwipsPerPixelX
mouse.Top = Me.Top / Screen.TwipsPerPixelY
mouse.Right = (Me.Left + Me.Width) / Screen.TwipsPerPixelX
mouse.Bottom = (Me.Top + Me.Height) / Screen.TwipsPerPixelY
ClipCursor mouse
End Sub
Private Sub Command2_Click()
ClipCursorBynum 0
End Sub

Private Sub Command3_Click()
ClipCursorBynum 0
Unload Me
End Sub

Private Sub Form_Load()
Command1.Caption = "限制鼠标"
Command2.Caption = "解除限制"
Command3.Caption = "退出"
End Sub

Private Sub Form_Terminate()
ClipCursorBynum 0
Unload Me
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式