VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Use ClipCursor API function to keep the mouse pointer inside a form.

by Anonymous (267 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Wed 1st September 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Use ClipCursor API function to keep the mouse pointer inside a form.

API Declarations


Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long

Rate Use ClipCursor API function to keep the mouse pointer inside a form.



Dim lngX As Long
Dim lngY As Long
Dim lngReturn As Long
Dim NewRect As RECT

'Get the screens Twips per pixel (form's scalemode must be Twips)
lngX = Screen.TwipsPerPixelX
lngY = Screen.TwipsPerPixelY

'Set cursor region to that of form
With NewRect
    .Left = Me.Left / lngX
    .Top = Me.Top / lngY
    .Right = .Left + Me.Width / lngX
    .Bottom = .Top + Me.Height / lngY
End With
lngReturn = ClipCursor(NewRect)

Download this snippet    Add to My Saved Code

Use ClipCursor API function to keep the mouse pointer inside a form. Comments

No comments have been posted about Use ClipCursor API function to keep the mouse pointer inside a form.. Why not be the first to post a comment about Use ClipCursor API function to keep the mouse pointer inside a form..

Post your comment

Subject:
Message:
0/1000 characters