Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Stop the mouse from going outside the form or any ...
Author:
Alintan Fernandez
E-mail:
Click to e-mail author
Submitted:
4/18/2002
Version:
VB6
Compatibility:
VB6
Category:
Windows API
Views:
12647
Stop the mouse from going outside the form or any other object with api functions.
Declarations:
Private Declare Sub ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINT) Private Declare Sub ClipCursor Lib "user32" (lpRect As Any) Private Declare Sub OffsetRect Lib "user32" (lpRect As RECT, ByVal X As Long, ByVal Y As Long) Private Declare Sub GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) Private Type RECT Left As Integer Top As Integer Right As Integer Bottom As Integer End Type Private Type POINT X As Long Y As Long End Type
Code:
'Add two command buttons Private Sub Command1_Click() Dim Client As RECT Dim Up As POINT ClientToScreen Me.hwnd, Up GetClientRect Me.hwnd, Client OffsetRect Client, Up.X, Up.Y Up.X = Client.Left Up.Y = Client.Top ClipCursor Client End Sub Private Sub Command2_Click() ClipCursor ByVal 0& End Sub 'You can stop the mouse to go outside any other object by replacing me.hwnd with label1.hwnd or text1.hwnd
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement