Cursor.Clip Cursor.Clip Cursor.Clip Cursor.Clip Property

定義

取得或設定表示游標裁剪方框的範圍。Gets or sets the bounds that represent the clipping rectangle for the cursor.

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; }
member this.Clip : System.Drawing.Rectangle with get, set
Public Shared Property Clip As Rectangle

屬性值

Rectangle,代表在螢幕座標中 Cursor 的裁剪方框。The Rectangle that represents the clipping rectangle for the Cursor, in screen coordinates.

範例

下列程式碼範例會從Current游標的Handle處建立游標, 並變更其位置和裁剪矩形。The following code example creates a cursor from the Current cursor's Handle, changes its position and clipping rectangle. 結果是, 游標會在執行程式碼的位置上向上移動和左50圖元。The result is the cursor will move up and to the left 50 pixels from where it is when the code is executed. 此外, 游標的裁剪矩形也會變更為表單的範圍 (根據預設, 它是使用者的整個畫面)。Additionally, the cursor's clipping rectangle is changed to the bounds of the form (by default it is the user's whole screen). 這個範例會要求您具有Form Button和, 以便在按一下時呼叫此程式碼。This example requires that you have a Form and a Button to call this code when it is clicked.

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

備註

裁剪的資料指標只允許在其裁剪矩形內移動。A clipped cursor is allowed to move only within its clipping rectangle. 一般而言, 只有在目前已捕捉到滑鼠時, 系統才會允許此情況。Generally, the system allows this only if the mouse is currently captured. 如果游標目前並未裁剪, 則產生的矩形會包含整個螢幕的維度。If the cursor is not currently clipped, the resulting rectangle contains the dimensions of the entire screen.

安全性

UIPermission
供所有視窗設定此屬性。for all windows to set this property. 相關聯的列舉:AllWindowsAssociated enumeration: AllWindows

適用於