Cursor.Position Propiedad

Definición

Obtiene o establece la posición del cursor.

public:
 static property System::Drawing::Point Position { System::Drawing::Point get(); void set(System::Drawing::Point value); };
public static System.Drawing.Point Position { get; set; }
static member Position : System.Drawing.Point with get, set
Public Shared Property Position As Point

Valor de propiedad

Point que representa la posición del cursor en coordenadas de la pantalla.

Ejemplos

En el Current ejemplo de código siguiente se crea un cursor a partir de Handle, se cambia su posición y el rectángulo de recorte. El resultado es que el cursor se moverá hacia arriba y a la izquierda 50 píxeles desde donde se ejecuta el código. Además, el rectángulo de recorte del cursor se cambia a los límites del formulario (de forma predeterminada es toda la pantalla del usuario). En este ejemplo se requiere y Form para Button llamar a este código cuando se hace clic en él.

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

Comentarios

La Position propiedad es idéntica a la Control.MousePosition propiedad .

Se aplica a

Consulte también