Cursor.Position Propriedade

Definição

Obtém ou define a posição do 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; }
member this.Position : System.Drawing.Point with get, set
Public Shared Property Position As Point

Valor da propriedade

Point

Um Point que representa o a posição do cursor em coordenadas da tela.

Exemplos

O exemplo de código a seguir cria um cursor do Current cursor Handle, altera sua posição e retângulo de recorte. O resultado é que o cursor se moverá para cima e para a esquerda 50 pixels de onde ele está quando o código é executado. Além disso, o retângulo de recorte do cursor é alterado para os limites do formulário (por padrão, é a tela inteira do usuário). Este exemplo requer um Form e um Button para chamar esse código quando ele é clicado.

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

Comentários

A Position propriedade é idêntica à Control.MousePosition propriedade.

Aplica-se a

Confira também