Cursor.Handle Egenskap

Definition

Hämtar markörens handtag.

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

Egenskapsvärde

IntPtr

nativeint

En IntPtr som representerar markörens handtag.

Undantag

Referensvärdet är Zero.

Exempel

I följande kodexempel skapas en markör från Current markörens Handle, ändrar dess position och urklippsrektangeln. Resultatet är att markören flyttas upp och till vänster 50 bildpunkter från där den körs. Dessutom ändras markörens urklippsrektangeln till formulärets gränser (som standard är det användarens hela skärm). Det här exemplet kräver en Form och en Button för att anropa den här koden när den klickas.

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

Kommentarer

Det här är inte en kopia av handtaget. bortskaffa den inte.

Gäller för

Se även