ClipCursor Reference in C#, VB.NET and VB6
Visual Basic 6 definition
Visual Basic 6 example source code
Declare Function ClipCursor Lib "user32.dll" (lpRect As RECT) As Long
Visual Basic .NET definition
Declare Function ClipCursor Lib "user32" (ByRef lpRect As Object) As Integer
ClipCursor confines the mouse cursor to a rectangular area of the screen. If the user tries to move the cursor outside of this bounding region or a call to SetCursorPos tells it to go outside the box, the cursor will immediately returned to the area. There is no way to get it out. This bounding effect will last in whatever program you switch to, and will remain even if the program that confined the cursor closes! The only way to "release" the cursor is to "confine" it to the entire screen (see example). It isn't usually a good idea to confine the cursor, since the user expects to move the cursor anywhere (not to mention the disasterous effect if your program quit before releasing the cursor!).
Confines the cursor to a rectangular area on the screen.
If an error occured, the function returns zero (call GetLastError to get the error code). If successful, the function returns a non-zero value.
For further information on Windows API functions such as these, and how to use these API's in your
C# and VB.NET applications, please refer to the book 'Network programming in .NET' (Buy at Amazon UK)
(Buy at Amazon US)
C# example source code
Provide a code example
Copyright 2013 Open Merchant Account Ltd.