Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB.NET
Expertise: beginner
Dec 1, 2001

Mouse clipping with the Cursor class

The Clip property of the System.Windows.Forms.Cursor class represents the rectangle within which the mouse cursor is confined, or Nothing if the mouse can move over the entire screen. This rectangle is in screen coordinates, so you must do some conversions if you want to confine the mouse to an object on the form, or the form itself. This task is made easy by the ClientRectangle property and the RectangleToScreen method that all visible controls expose:

' Clip the mouse to the TextBox1 control's client area.
Cursor.Clip = TextBox1.RectangleToScreen(TextBox1.ClientRectangle)

' ...

' Free the mouse cursor.
Cursor.Clip = Nothing
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date