vb怎么实现禁止鼠标移动三十秒?三十秒后才可以移动?
2013-12-08
展开全部
Option Explicit
Dim R As RECT
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Sub ClipCursor Lib "user32" (lpRect As Any)
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Dim i As IntegerPrivate Sub Form_Load()
Me.WindowState = 2 '窗体启动时最大化
Timer1.Interval = 30000
End SubPrivate Sub Timer1_Timer()
i = i + 1
If i Mod 2 = 0 Then
SetRect R, 1, 1, 1, 1
ClipCursor R
i = 0
Else
ClipCursor 0
End If
End Sub
Dim R As RECT
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Sub ClipCursor Lib "user32" (lpRect As Any)
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Dim i As IntegerPrivate Sub Form_Load()
Me.WindowState = 2 '窗体启动时最大化
Timer1.Interval = 30000
End SubPrivate Sub Timer1_Timer()
i = i + 1
If i Mod 2 = 0 Then
SetRect R, 1, 1, 1, 1
ClipCursor R
i = 0
Else
ClipCursor 0
End If
End Sub
2013-12-08
展开全部
你参考参考,希望你能做出来:'控件:Command1,Command2,Command3,Command4.Option Explicit
Dim R As RECT
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Sub ClipCursor Lib "user32" (lpRect As Any)
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As LongPrivate Sub Command1_Click()
SetRect R, Left / Screen.TwipsPerPixelX + Command4.Left, Top / Screen.TwipsPerPixelY + Command4.Top, Left / Screen.TwipsPerPixelX + Command4.Left + Command4.Width, Top / Screen.TwipsPerPixelY + Command4.Top + Command4.Height
ClipCursor R
End SubPrivate Sub Command2_Click()
ShowCursor False
End SubPrivate Sub Command3_Click()
ShowCursor True
End SubPrivate Sub Command4_Click()
ClipCursor 0
End SubPrivate Sub Form_Load()
ScaleMode = vbPixels
Command1.Caption = "限制鼠标区域"
Command2.Caption = "隐藏鼠标"
Command3.Caption = "显示鼠标"
Command4.Caption = "清除鼠标区域限制"
End Sub
Dim R As RECT
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Sub ClipCursor Lib "user32" (lpRect As Any)
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As LongPrivate Sub Command1_Click()
SetRect R, Left / Screen.TwipsPerPixelX + Command4.Left, Top / Screen.TwipsPerPixelY + Command4.Top, Left / Screen.TwipsPerPixelX + Command4.Left + Command4.Width, Top / Screen.TwipsPerPixelY + Command4.Top + Command4.Height
ClipCursor R
End SubPrivate Sub Command2_Click()
ShowCursor False
End SubPrivate Sub Command3_Click()
ShowCursor True
End SubPrivate Sub Command4_Click()
ClipCursor 0
End SubPrivate Sub Form_Load()
ScaleMode = vbPixels
Command1.Caption = "限制鼠标区域"
Command2.Caption = "隐藏鼠标"
Command3.Caption = "显示鼠标"
Command4.Caption = "清除鼠标区域限制"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-12-08
展开全部
在mousemove事件里面把鼠标定格在原来的位置就可以了啊。再使用一个timer事件中添加一个判断标志。用着个标志来控制是不是进制移动
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询