Cursor Constructor (IntPtr)
.NET Framework (current version)
Initializes a new instance of the Cursor class from the specified Windows handle.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
| Exception | Condition |
|---|---|
| ArgumentException | handle is IntPtr::Zero. |
You must free the cursor handle when you are done with it. For more information about disposing of resources, see Cleaning Up Unmanaged Resources.
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.
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); }
.NET Framework
Available since 1.1
Available since 1.1
Show: