Cursor Clip Property (System Windows Forms)
Cursor Clip Property (System Windows Forms)
Forms)
Dropdown Arrow
Microsoft.com
Welcome Sign in
Submit Query
Web
Add To Favorites
Send
Add
MSDN
MSDN Library
System.Windows.Forms Namespace
Switch on low bandwidth view Language Collapse Collapse Language Filter All All/Expand Filter .NET Framework Class Library All
Cursor.Clip Property
Gets or sets the bounds that represent the clipping rectangle for the cursor. Namespace: System.Windows.Forms
This page is specific to Microsoft Visual Studio 2008/.NET Framework 3.5 Other versions are also available for the following: Microsoft Visual Studio 2003/.NET Framework 1.1
Syntax
C#
Visual C++
public: static property Rectangle Clip { Rectangle get (); void set (Rectangle value); }
JScript
public static function get Clip () : Rectangle public static function set Clip (value : Rectangle)
Property Value Type: System.Drawing.Rectangle The Rectangle that represents the clipping rectangle for the Cursor, in screen coordinates.
Remarks
A clipped cursor is allowed to move only within its clipping rectangle. Generally, the system allows this only if the mouse is currently captured. If the cursor is not currently clipped, the resulting rectangle contains the dimensions of the entire screen.
Examples
The following code example creates a cursor from the Current cursor's Handle, changes its position and clipping rectangle. The result is the cursor will move up and to the left 50 pixels from where it is when the code is executed. Additionally, the cursor's clipping rectangle is changed to the bounds of the form (by default it is the user's whole screen). This example requires that you have a Form and a Button to call this code when it is clicked. Visual Basic Copy Code
Private Sub MoveCursor() ' Set the Current cursor, move the cursor's Position, ' and set its clipping rectangle to the form. Me.Cursor = New Cursor(Cursor.Current.Handle) Cursor.Position = New Point(Cursor.Position.X - 50, Cursor.Position.Y - 50) Cursor.Clip = New Rectangle(Me.Location, Me.Size) End Sub
C#
Copy Code
// Set the Current cursor, move the cursor's Position, // and set its clipping rectangle to the form. this.Cursor = new Cursor(Cursor.Current.Handle); Cursor.Position = new Point(Cursor.Position.X - 50, Cursor.Position.Y - 50); Cursor.Clip = new Rectangle(this.Location, this.Size); }
Visual C++
Copy Code
void MoveCursor() { // Set the Current cursor, move the cursor's Position, // and set its clipping rectangle to the form. this->Cursor = gcnew System::Windows::Forms::Cursor( ::Cursor::Current->Handle ); ::Cursor::Position = Point(::Cursor::Position.X - 50,::Cursor::Position.Y - 50); ::Cursor::Clip = Rectangle(this->Location,this->Size); }
UIPermission for all windows to set this property. Associated enumeration: UIPermissionWindow.AllWindows
Platforms
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98 The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information
.NET Framework Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
See Also
Reference Cursor Class Cursor Members System.Windows.Forms Namespace
this?
Community Content
Add new content
Annotations RSS
Privacy Statement