Cursor.Position 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定游標的位置。
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
屬性值
代表 Point 游標在螢幕座標中的位置。
範例
以下程式碼範例將游標的 Current , 建立一個游標,改變 Handle其位置與裁切矩形。 結果是游標會從執行程式碼時的位置往上移動並向左移動 50 像素。 此外,游標的裁切矩形會被改成表單的邊界(預設是使用者的整個畫面)。 此範例需要 a Form 和 a Button 來在點擊時呼叫此程式碼。
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
備註
該 Position 物業與該 Control.MousePosition 物業相同。