Saturday, May 18, 2013
 
    Search Web Link
Search Software
    
API Home » Cursor » ClipCursor

ClipCursor

Category: Cursor
Hits: 4880 Rating: ClipCursor has been rated 1.72 by  776 users (1.72) votes 776
Rate: 1-star  2-stars  3-stars  4-stars  5-stars
E-mail this API to friend E-mail this Code to a friend  save Bookmark this VB API Function
API Explanation
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!). The return value is 0 if an error occured, or 1 if it is successful.

Parameter Information
Declare Function ClipCursor Lib "user32.dll" (lpRect As RECT) As Long

lpRect
The rectangle (in screen coordinates) defining the confinement rectangle.
Code



' Confine the cursor temporarily to inside of Form1

' ** Place the following code where you want to confine the cursor. **
Dim r As RECT ' confinement rectangle
Dim retval As Long ' return value

retval = GetWindowRect(Form1.hWnd, r) ' put window's coordinates into r
retval = ClipCursor(r) ' confine the cursor

' ** Place the following code where you want to release the cursor. **
Dim r As RECT, retval As Long
Dim deskhWnd As Long ' the handle of the desktop window

deskhWnd = GetDesktopWindow() ' get handle of the desktop window
retval = GetWindowRect(deskhWnd, r) ' put window's coordinates into r
retval = ClipCursor(r) ' "confine" the cursor to the entire screen




HOME | MUSIC | DOWNLOADS |  GAMES | TEST-QUIZZES | SITEMAP | ABOUT | HELP
Copyright © 2000 - 2013 Ex-designz. All rights reserved. Website Developed By Dexter Zafra of Myasp-net.com
Link to us | Advertisement | Contact us | Privacy Policy | Terms of use | Accessibility