vb锁定鼠标(0,0)

来源:百度知道 编辑:UC知道 时间:2024/06/15 12:24:21
vb6,可用的

绝对可用http://hi.baidu.com/loveee/blog/item/e51f99165f156759f3de3298.html

Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
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
Const HWND_TOPMOST = -1
Const SWP_SHOWWINDOW = &H40
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim mouse As RECT

'将鼠标限制在屏幕左上角无法移动
Private Sub Form_Load()
Dim retValue As Long
retValue = SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, Screen.Width, Screen.Height, SWP_SHOWWINDOW)
mouse.Left = 0
mouse.Top = 0
mouse.Right = 0
mouse.Bottom = 0
ClipCursor mouse