Cursor.Clip 属性

定义

获取或设置表示光标的剪辑矩形的边界。

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 的剪辑矩形的 Rectangle(采用屏幕坐标的形式)。

示例

下面的代码示例从 Current 游标创建 Handle游标,更改其位置和剪裁矩形。 结果是光标将向上和向左移动 50 像素,在该位置执行代码。 此外,光标的剪辑矩形默认更改为窗体的边界, (默认为用户的整个屏幕) 。 本示例要求单击此代码时有一个 Form 和一个 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

注解

仅允许剪裁的光标在其剪裁矩形内移动。 通常,仅当当前捕获鼠标时,系统才允许这样做。 如果光标当前未剪裁,则生成的矩形包含整个屏幕的尺寸。

适用于