This website has been designed for use with the FireFox browser. Please use FireFox to view this page.
ClipCursor Reference in C#, VB.NET and VB6
Library:user32.dll
Visual Basic 6 definition
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
Description
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!).
ClipCursor
Confines the cursor to a rectangular area on the screen.
System.Windows.Forms.Cursor.Clip
Return Value
If an error occured, the function returns zero (call GetLastError to get the error code). If successful, the function returns a non-zero value.
Parameters
Further Information:
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)