共用方式為


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 圖元。 此外,游標的裁剪矩形預設會變更為表單 (的界限,這是使用者的整個螢幕) 。 此範例需要 FormButton ,才能在按一下程式碼時呼叫此程式碼。

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

備註

這不是控制碼的複本;請勿處置它。

適用於

另請參閱