设定Mouse 在某个固定范围

冰丰防静电地板

冰丰防静电地板

2016-02-19 16:50

下面这个设定Mouse 在某个固定范围教程由图老师小编精心推荐选出,过程简单易学超容易上手,喜欢就要赶紧get起来哦!
Type RECT    Left As Long    Top As Long    Right As Long    Bottom As LongEnd TypeDeclare Function ClipCursor Lib "user32" (lpRect As Any) As LongDeclare Function ShowCursor Lib "user32" (ByVal bShow As Long) As LongDeclare Function SetCursorPos Lib "user32" (ByVal x As Long, _    ByVal y As Long) As LongDeclare Function GetWindowRect Lib "user32" Alias "GetWindowRect" _    (ByVal hwnd As Long, lpRect As RECT) As Long'设定Mouse可移动的围是在某个control项之内Public Function toLockCursor(ByVal ctlHwnd As Long) As BooleanDim rect5 As RECTDim res As LongGetWindowRect ctlHwnd, rect5 '取得window的四个角rect5.Top = rect5.Toprect5.Left = rect5.Leftrect5.Bottom = rect5.Bottomrect5.Right = rect5.RightSetCursorPos (rect5.Top + rect5.Bottom)  2, (rect5.Left + rect5.Right)  2res = ClipCursor(rect5)If res = 1 Then  toLockCursor = TrueElse  toLockCursor = FalseEnd IfEnd Function'设定Mouse移动的围为个萤幕Public Sub toUnLockCursor()Dim rscreen As RECTrscreen.Top = 0rscreen.Left = 0rscreen.Right = Screen.Width  Screen.TwipsPerPixelXrscreen.Bottom = Screen.Height  Screen.TwipsPerPixelYClipCursor rscreenEnd Sub例如:设定Mouse只能在Form的范围Private Sub Command1.Click()Call toLockCursor(Me.hWnd)End SubPrivate Sub Command2.Click()Call toUnLockCursor()End Sub
展开更多 50%)
分享

猜你喜欢

设定Mouse 在某个固定范围

编程语言 网络编程
设定Mouse 在某个固定范围

怎样在Excel中计算比某个固定数大的最小数字

excel
怎样在Excel中计算比某个固定数大的最小数字

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

羊水指数正常范围 羊水在什么范围比较安全

羊水指数正常范围 羊水指数 孕妇
羊水指数正常范围 羊水在什么范围比较安全

如何自动移动Mouse

编程语言 网络编程
如何自动移动Mouse

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

vb实现隐藏Mouse

编程语言 网络编程
vb实现隐藏Mouse

副乳手术在医保范围吗

整容
副乳手术在医保范围吗

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

取得Disk Volume Information

取得Disk Volume Information

创造世界上最简单的 PHP 开发模式(1)

创造世界上最简单的 PHP 开发模式(1)
下拉加载更多内容 ↓