Share via


Cursor.Handle Properti

Definisi

Mendapatkan handel kursor.

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

Nilai Properti

IntPtr

nativeint

Yang IntPtr mewakili handel kursor.

Pengecualian

Nilai handelnya adalah Zero.

Contoh

Contoh kode berikut membuat kursor dari Current kursor Handle, mengubah posisinya dan mengklip persegi panjang. Hasilnya adalah kursor akan bergerak ke atas dan ke kiri 50 piksel dari tempatnya ketika kode dijalankan. Selain itu, persegi panjang kliping kursor diubah ke batas formulir (secara default itu adalah seluruh layar pengguna). Contoh ini memerlukan Form dan Button untuk memanggil kode ini saat diklik.

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

Keterangan

Ini bukan salinan handel; jangan membuangnya.

Berlaku untuk

Lihat juga