Cursor.Handle Właściwość

Definicja

Pobiera uchwyt kursora.

public:
 property IntPtr Handle { IntPtr get(); };
public IntPtr Handle { get; }
member this.Handle : nativeint
Public ReadOnly Property Handle As IntPtr

Wartość właściwości

IntPtr

nativeint

Element IntPtr reprezentujący uchwyt kursora.

Wyjątki

Wartość uchwytu to Zero.

Przykłady

Poniższy przykład kodu tworzy kursor na podstawie Current kursora Handle, zmienia położenie i przycinanie prostokąta. Wynikiem jest przesunięcie kursora w górę i do lewej 50 pikseli z miejsca, w którym jest wykonywany kod. Ponadto prostokąt przycinania kursora jest zmieniany na granice formularza (domyślnie jest to cały ekran użytkownika). W tym przykładzie jest wymagany Form element i , Button aby wywołać ten kod po kliknięciu.

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);

}
private void MoveCursor()
{
   // 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);
}
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

Uwagi

Nie jest to kopia uchwytu; nie usuwaj go.

Dotyczy

Zobacz też