Cursor.Handle 属性

定义

获取光标句柄。

public:
 property IntPtr Handle { IntPtr get(); };
public IntPtr Handle { get; }
member this.Handle : nativeint
Public ReadOnly Property Handle As IntPtr

属性值

IntPtr

nativeint

一个 IntPtr,代表光标句柄。

例外

句柄值为 Zero

示例

下面的代码示例从 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

注解

这不是句柄的副本;不要释放它。

适用于

另请参阅