Cursor.Clip 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定代表游標裁切矩形的界限。
public:
static property System::Drawing::Rectangle Clip { System::Drawing::Rectangle get(); void set(System::Drawing::Rectangle value); };
public static System.Drawing.Rectangle Clip { get; set; }
static member Clip : System.Drawing.Rectangle with get, set
Public Shared Property Clip As Rectangle
屬性值
該 Rectangle 代表 在螢幕座標中 的 Cursor裁剪矩形。
範例
以下程式碼範例將游標的 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
備註
被裁剪的游標只能在其裁剪矩形內移動。 一般來說,系統只允許在老鼠目前被捕獲時進行。 如果游標目前沒有被裁切,產生的矩形會包含整個螢幕的尺寸。