語言

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 游標的柄。

例外狀況

handle值為 Zero。

範例

以下程式碼範例將游標的 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

備註

這不是手柄的複製品;不要丟棄它。

適用於

另請參閱