Cursors 类

提供由 Windows 窗体应用程序使用的 Cursor 对象的集合。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public NotInheritable Class Cursors
用法
Dim instance As Cursors
public sealed class Cursors
public ref class Cursors sealed
public final class Cursors
public final class Cursors

备注

该类中某些 Cursor 对象的外观可以与所描述的那些对象不同。用户可以通过在操作系统中调整鼠标指针的设置来更改光标外观。平移光标和静止光标是静态光标,操作系统无法更改它们。

鼠标滚轮操作过程中使用平移光标和静止光标。当单击鼠标滚轮时,根据窗口可以滚动的方向,光标更改为相应的静止光标。然后随着鼠标移动,光标更改为相应的平移光标。

示例

下面的示例演示了如何使用 Control.Cursor 属性、Cursor 类和 Cursors 类来更改鼠标光标。本示例创建了一个包含 ComboBox 控件、Panel 控件和 ListView 控件的窗体。ComboBox 包含了由 Cursors 类提供的所有光标。当用户在 ComboBox 中选择了鼠标光标时,Control.Cursor 属性将设置为选定的光标,这将更新 Panel 的光标。每次发生 Control.CursorChanged 事件时,都会更新 ListView

Imports System
Imports System.Drawing
Imports System.Windows.Forms

Namespace MCursor
    
    ' Summary description for Form1.
    Public NotInheritable Class Form1
        Inherits System.Windows.Forms.Form

        Friend WithEvents cursorSelectionComboBox As System.Windows.Forms.ComboBox
        Friend WithEvents testPanel As System.Windows.Forms.Panel

        Private label1 As System.Windows.Forms.Label
        Private label2 As System.Windows.Forms.Label
        Private cursorEventViewer As System.Windows.Forms.ListView
        Private label3 As System.Windows.Forms.Label

        <System.STAThread()> _
        Public Shared Sub Main()
            System.Windows.Forms.Application.Run(New Form1)
        End Sub 'Main

        Public Sub New()

            Me.cursorSelectionComboBox = New System.Windows.Forms.ComboBox
            Me.testPanel = New System.Windows.Forms.Panel
            Me.label1 = New System.Windows.Forms.Label
            Me.label2 = New System.Windows.Forms.Label
            Me.cursorEventViewer = New System.Windows.Forms.ListView
            Me.label3 = New System.Windows.Forms.Label

            ' Select Cursor Label
            Me.label2.Location = New System.Drawing.Point(24, 16)
            Me.label2.Size = New System.Drawing.Size(80, 16)
            Me.label2.Text = "Select cursor:"            '

            ' Cursor Testing Panel Label
            Me.label1.Location = New System.Drawing.Point(24, 80)
            Me.label1.Size = New System.Drawing.Size(144, 23)
            Me.label1.Text = "Cursor testing panel:"

            ' Cursor Changed Events Label
            Me.label3.Location = New System.Drawing.Point(184, 16)
            Me.label3.Size = New System.Drawing.Size(128, 16)
            Me.label3.Text = "Cursor changed events:"

            ' Cursor Selection ComboBox
            Me.cursorSelectionComboBox.Location = New System.Drawing.Point(24, 40)
            Me.cursorSelectionComboBox.Size = New System.Drawing.Size(152, 21)
            Me.cursorSelectionComboBox.TabIndex = 0

            ' Cursor Test Panel
            Me.testPanel.BackColor = System.Drawing.SystemColors.ControlDark
            Me.testPanel.Location = New System.Drawing.Point(24, 104)
            Me.testPanel.Size = New System.Drawing.Size(152, 160)

            ' Cursor Event ListView
            Me.cursorEventViewer.Location = New System.Drawing.Point(184, 40)
            Me.cursorEventViewer.Size = New System.Drawing.Size(256, 224)
            Me.cursorEventViewer.TabIndex = 4
            Me.cursorEventViewer.View = System.Windows.Forms.View.List

            ' Set up how the form should be displayed and add the controls to the form.
            Me.ClientSize = New System.Drawing.Size(456, 286)
            Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.label3, _
                                    Me.cursorEventViewer, Me.label2, Me.label1, _
                                    Me.testPanel, Me.cursorSelectionComboBox})

            Me.Text = "Cursors Example"

            ' Add all the cursor types to the combobox.
            Dim cursor As Cursor
            For Each cursor In CursorList()
                cursorSelectionComboBox.Items.Add(cursor)
            Next cursor
        End Sub 'New 

        Private Function CursorList() As Cursor()
            ' Make an array of all the types of cursors in Windows Forms.
            return New Cursor() {Cursors.AppStarting, Cursors.Arrow, Cursors.Cross, _
                                 Cursors.Default, Cursors.Hand, Cursors.Help, _
                                 Cursors.HSplit, Cursors.IBeam, Cursors.No, _
                                 Cursors.NoMove2D, Cursors.NoMoveHoriz, Cursors.NoMoveVert, _
                                 Cursors.PanEast, Cursors.PanNE, Cursors.PanNorth, _
                                 Cursors.PanNW, Cursors.PanSE, Cursors.PanSouth, _
                                 Cursors.PanSW, Cursors.PanWest, Cursors.SizeAll, _
                                 Cursors.SizeNESW, Cursors.SizeNS, Cursors.SizeNWSE, _
                                 Cursors.SizeWE, Cursors.UpArrow, Cursors.VSplit, Cursors.WaitCursor}
        End Function

        Private Sub cursorSelectionComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cursorSelectionComboBox.SelectedIndexChanged
            ' Set the cursor in the test panel to be the selected cursor style.
            testPanel.Cursor = CType(cursorSelectionComboBox.SelectedItem, Cursor)

        End Sub 

        Private Sub testPanel_CursorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles testPanel.CursorChanged
            ' Build up a string containing the type of object sending the event, and the event.
            Dim cursorEvent As String = String.Format("[{0}]: {1}", sender.GetType().ToString(), "Cursor changed")

            ' Records this event in the list view.
            Me.cursorEventViewer.Items.Add(cursorEvent)

        End Sub 

    End Class 'Form1
End Namespace 'MCursor
using System;
using System.Drawing;
using System.Windows.Forms;

namespace MCursor
{
    public class Form1 : System.Windows.Forms.Form
    {
        private System.Windows.Forms.ComboBox cursorSelectionComboBox;

        private System.Windows.Forms.Panel testPanel;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.ListView cursorEventViewer;
        private System.Windows.Forms.Label label3;
        
        [STAThread]
        static void Main() 
        {
            Application.Run(new Form1());
        }

        public Form1()
        {
            this.cursorSelectionComboBox = new System.Windows.Forms.ComboBox();
            this.testPanel = new System.Windows.Forms.Panel();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.cursorEventViewer = new System.Windows.Forms.ListView();
            this.label3 = new System.Windows.Forms.Label();

            // Select Cursor Label
            this.label2.Location = new System.Drawing.Point(24, 16);
            this.label2.Size = new System.Drawing.Size(80, 16);
            this.label2.Text = "Select cursor:";

            // Cursor Testing Panel Label
            this.label1.Location = new System.Drawing.Point(24, 80);
            this.label1.Size = new System.Drawing.Size(144, 23);
            this.label1.Text = "Cursor testing panel:";

            // Cursor Changed Events Label
            this.label3.Location = new System.Drawing.Point(184, 16);
            this.label3.Size = new System.Drawing.Size(128, 16);
            this.label3.Text = "Cursor changed events:";
            
            // Cursor Selection ComboBox
            this.cursorSelectionComboBox.Location = new System.Drawing.Point(24, 40);
            this.cursorSelectionComboBox.Size = new System.Drawing.Size(152, 21);
            this.cursorSelectionComboBox.TabIndex = 0;
            this.cursorSelectionComboBox.SelectedIndexChanged += 
                 new System.EventHandler(this.cursorSelectionComboBox_SelectedIndexChanged);

            // Cursor Test Panel
            this.testPanel.BackColor = System.Drawing.SystemColors.ControlDark;
            this.testPanel.Location = new System.Drawing.Point(24, 104);
            this.testPanel.Size = new System.Drawing.Size(152, 160);
            this.testPanel.CursorChanged += new System.EventHandler(this.testPanel_CursorChanged);

            // Cursor Event ListView
            this.cursorEventViewer.Location = new System.Drawing.Point(184, 40);
            this.cursorEventViewer.Size = new System.Drawing.Size(256, 224);
            this.cursorEventViewer.TabIndex = 4;
            this.cursorEventViewer.View = System.Windows.Forms.View.List;

            // Set up how the form should be displayed and add the controls to the form.
            this.ClientSize = new System.Drawing.Size(456, 286);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                        this.label3, this.cursorEventViewer,
                                        this.label2, this.label1,
                                        this.testPanel, this.cursorSelectionComboBox});

            this.Text = "Cursors Example";

            // Add all the cursor types to the combobox.
            foreach (Cursor cursor in CursorList())
            {
                cursorSelectionComboBox.Items.Add(cursor);
            }
        
        }

        private Cursor [] CursorList()
        {

            // Make an array of all the types of cursors in Windows Forms.
            return new Cursor [] {
                                     Cursors.AppStarting, Cursors.Arrow, Cursors.Cross,
                                     Cursors.Default, Cursors.Hand, Cursors.Help,
                                     Cursors.HSplit, Cursors.IBeam, Cursors.No,
                                     Cursors.NoMove2D, Cursors.NoMoveHoriz, Cursors.NoMoveVert,
                                     Cursors.PanEast, Cursors.PanNE, Cursors.PanNorth,
                                     Cursors.PanNW, Cursors.PanSE, Cursors.PanSouth,
                                     Cursors.PanSW, Cursors.PanWest, Cursors.SizeAll,
                                     Cursors.SizeNESW, Cursors.SizeNS, Cursors.SizeNWSE,
                                     Cursors.SizeWE, Cursors.UpArrow, Cursors.VSplit, Cursors.WaitCursor};

        }

        private void cursorSelectionComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            // Set the cursor in the test panel to be the selected cursor style.
            testPanel.Cursor = (Cursor)cursorSelectionComboBox.SelectedItem;
        }

        private void testPanel_CursorChanged(object sender, System.EventArgs e)
        {
            // Build up a string containing the type of object sending the event, and the event.
            string cursorEvent = string.Format("[{0}]: {1}", sender.GetType().ToString(), "Cursor changed");                
        
            // Record this event in the list view.
            this.cursorEventViewer.Items.Add(cursorEvent);
        }
    }
}
#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

namespace MCursor
{
   public ref class Form1: public System::Windows::Forms::Form
   {
   private:
      System::Windows::Forms::ComboBox^ cursorSelectionComboBox;
      System::Windows::Forms::Panel^ testPanel;
      System::Windows::Forms::Label ^ label1;
      System::Windows::Forms::Label ^ label2;
      System::Windows::Forms::ListView^ cursorEventViewer;
      System::Windows::Forms::Label ^ label3;

   public:
      Form1()
      {
         this->cursorSelectionComboBox = gcnew System::Windows::Forms::ComboBox;
         this->testPanel = gcnew System::Windows::Forms::Panel;
         this->label1 = gcnew System::Windows::Forms::Label;
         this->label2 = gcnew System::Windows::Forms::Label;
         this->cursorEventViewer = gcnew System::Windows::Forms::ListView;
         this->label3 = gcnew System::Windows::Forms::Label;
         
         // Select Cursor Label
         this->label2->Location = System::Drawing::Point( 24, 16 );
         this->label2->Size = System::Drawing::Size( 80, 16 );
         this->label2->Text = "Select cursor:";
         
         // Cursor Testing Panel Label
         this->label1->Location = System::Drawing::Point( 24, 80 );
         this->label1->Size = System::Drawing::Size( 144, 23 );
         this->label1->Text = "Cursor testing panel:";
         
         // Cursor Changed Events Label
         this->label3->Location = System::Drawing::Point( 184, 16 );
         this->label3->Size = System::Drawing::Size( 128, 16 );
         this->label3->Text = "Cursor changed events:";
         
         // Cursor Selection ComboBox
         this->cursorSelectionComboBox->Location = System::Drawing::Point( 24, 40 );
         this->cursorSelectionComboBox->Size = System::Drawing::Size( 152, 21 );
         this->cursorSelectionComboBox->TabIndex = 0;
         this->cursorSelectionComboBox->SelectedIndexChanged += gcnew System::EventHandler( this, &Form1::cursorSelectionComboBox_SelectedIndexChanged );
         
         // Cursor Test Panel
         this->testPanel->BackColor = System::Drawing::SystemColors::ControlDark;
         this->testPanel->Location = System::Drawing::Point( 24, 104 );
         this->testPanel->Size = System::Drawing::Size( 152, 160 );
         this->testPanel->CursorChanged += gcnew System::EventHandler( this, &Form1::testPanel_CursorChanged );
         
         // Cursor Event ListView
         this->cursorEventViewer->Location = System::Drawing::Point( 184, 40 );
         this->cursorEventViewer->Size = System::Drawing::Size( 256, 224 );
         this->cursorEventViewer->TabIndex = 4;
         this->cursorEventViewer->View = System::Windows::Forms::View::List;
         
         // Set up how the form should be displayed and add the controls to the form.
         this->ClientSize = System::Drawing::Size( 456, 286 );
         array<System::Windows::Forms::Control^>^temp0 = {this->label3,this->cursorEventViewer,this->label2,this->label1,this->testPanel,this->cursorSelectionComboBox};
         this->Controls->AddRange( temp0 );
         this->Text = "Cursors Example";
         
         // Add all the cursor types to the combobox.
         System::Collections::IEnumerator^ myEnum = CursorList()->GetEnumerator();
         while ( myEnum->MoveNext() )
         {
            System::Windows::Forms::Cursor^ cursor = safe_cast<System::Windows::Forms::Cursor^>(myEnum->Current);
            cursorSelectionComboBox->Items->Add( cursor );
         }
      }


   private:
      array<System::Windows::Forms::Cursor^>^ CursorList()
      {
         
         // Make an array of all the types of cursors in Windows Forms.
         array<System::Windows::Forms::Cursor^>^temp1 = {Cursors::AppStarting,Cursors::Arrow,Cursors::Cross,Cursors::Default,Cursors::Hand,Cursors::Help,Cursors::HSplit,Cursors::IBeam,Cursors::No,Cursors::NoMove2D,Cursors::NoMoveHoriz,Cursors::NoMoveVert,Cursors::PanEast,Cursors::PanNE,Cursors::PanNorth,Cursors::PanNW,Cursors::PanSE,Cursors::PanSouth,Cursors::PanSW,Cursors::PanWest,Cursors::SizeAll,Cursors::SizeNESW,Cursors::SizeNS,Cursors::SizeNWSE,Cursors::SizeWE,Cursors::UpArrow,Cursors::VSplit,Cursors::WaitCursor};
         return temp1;
      }

      void cursorSelectionComboBox_SelectedIndexChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ )
      {
         
         // Set the cursor in the test panel to be the selected cursor style.
         testPanel->Cursor = dynamic_cast<System::Windows::Forms::Cursor^>(cursorSelectionComboBox->SelectedItem);
      }

      void testPanel_CursorChanged( Object^ sender, System::EventArgs^ /*e*/ )
      {
         
         // Build up a String* containing the type of Object* sending the event, and the event.
         String^ cursorEvent = String::Format( "[{0}]: {1}", sender->GetType(), "Cursor changed" );
         
         // Record this event in the list view.
         this->cursorEventViewer->Items->Add( cursorEvent );
      }

   };

}


[STAThread]
int main()
{
   Application::Run( gcnew MCursor::Form1 );
}
package MCursor;

import System.*;
import System.Drawing.*;
import System.Windows.Forms.*;
import System.Collections.*;

public class Form1 extends System.Windows.Forms.Form
{
    private System.Windows.Forms.ComboBox cursorSelectionComboBox;
    private System.Windows.Forms.Panel testPanel;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.ListView cursorEventViewer;
    private System.Windows.Forms.Label label3;

    /** @attribute STAThread()
     */
    public static void main(String[] args)
    {
        Application.Run(new Form1());
    } //main

    public Form1()
    {
        this.cursorSelectionComboBox = new System.Windows.Forms.ComboBox();
        this.testPanel = new System.Windows.Forms.Panel();
        this.label1 = new System.Windows.Forms.Label();
        this.label2 = new System.Windows.Forms.Label();
        this.cursorEventViewer = new System.Windows.Forms.ListView();
        this.label3 = new System.Windows.Forms.Label();
        // Select Cursor Label
        this.label2.set_Location(new System.Drawing.Point(24, 16));
        this.label2.set_Size(new System.Drawing.Size(80, 16));
        this.label2.set_Text("Select cursor:");
        // Cursor Testing Panel Label
        this.label1.set_Location(new System.Drawing.Point(24, 80));
        this.label1.set_Size(new System.Drawing.Size(144, 23));
        this.label1.set_Text("Cursor testing panel:");
        // Cursor Changed Events Label
        this.label3.set_Location(new System.Drawing.Point(184, 16));
        this.label3.set_Size(new System.Drawing.Size(128, 16));
        this.label3.set_Text("Cursor changed events:");
        // Cursor Selection ComboBox
        this.cursorSelectionComboBox.set_Location(
            new System.Drawing.Point(24, 40));
        this.cursorSelectionComboBox.set_Size(
            new System.Drawing.Size(152, 21));
        this.cursorSelectionComboBox.set_TabIndex(0);
        this.cursorSelectionComboBox.add_SelectedIndexChanged(
            new System.EventHandler(
            this.cursorSelectionComboBox_SelectedIndexChanged));
        // Cursor Test Panel
        this.testPanel.set_BackColor(
            System.Drawing.SystemColors.get_ControlDark());
        this.testPanel.set_Location(new System.Drawing.Point(24, 104));
        this.testPanel.set_Size(new System.Drawing.Size(152, 160));
        this.testPanel.add_CursorChanged(new System.EventHandler(
            this.testPanel_CursorChanged));
        // Cursor Event ListView
        this.cursorEventViewer.set_Location(new System.Drawing.Point(184, 40));
        this.cursorEventViewer.set_Size(new System.Drawing.Size(256, 224));
        this.cursorEventViewer.set_TabIndex(4);
        this.cursorEventViewer.set_View(System.Windows.Forms.View.List);
        // Set up how the form should be displayed and add the controls to the 
        // form.
        this.set_ClientSize(new System.Drawing.Size(456, 286));
        this.get_Controls().AddRange(new System.Windows.Forms.Control[] { 
            this.label3, this.cursorEventViewer, this.label2, this.label1,
            this.testPanel, this.cursorSelectionComboBox });

        this.set_Text("Cursors Example");

        IEnumerator myEnum = CursorList().GetEnumerator();
        // Add all the cursor types to the combobox.
        while (myEnum.MoveNext()) {
            Cursor cursor = ( Cursor)myEnum.get_Current();
            cursorSelectionComboBox.get_Items().Add(cursor);
        }
    } //Form1

    private Cursor[] CursorList()
    {
        // Make an array of all the types of cursors in Windows Forms.
        return new Cursor[] { Cursors.get_AppStarting(), Cursors.get_Arrow(), 
            Cursors.get_Cross(), Cursors.get_Default(), Cursors.get_Hand(), 
            Cursors.get_Help(), Cursors.get_HSplit(), Cursors.get_IBeam(), 
            Cursors.get_No(), Cursors.get_NoMove2D(), Cursors.get_NoMoveHoriz(), 
            Cursors.get_NoMoveVert(), Cursors.get_PanEast(), 
            Cursors.get_PanNE(), Cursors.get_PanNorth(), Cursors.get_PanNW(),
            Cursors.get_PanSE(), Cursors.get_PanSouth(), Cursors.get_PanSW(),
            Cursors.get_PanWest(), Cursors.get_SizeAll(), 
            Cursors.get_SizeNESW(), Cursors.get_SizeNS(), 
            Cursors.get_SizeNWSE(), Cursors.get_SizeWE(), 
            Cursors.get_UpArrow(), Cursors.get_VSplit(), 
            Cursors.get_WaitCursor() };
    } //CursorList

    private void cursorSelectionComboBox_SelectedIndexChanged(Object sender,
        System.EventArgs e)
    {
        // Set the cursor in the test panel to be the selected cursor style.
        testPanel.set_Cursor((Cursor)(cursorSelectionComboBox.
            get_SelectedItem()));
    } //cursorSelectionComboBox_SelectedIndexChanged

    private void testPanel_CursorChanged(Object sender, System.EventArgs e)
    {
        // Build up a string containing the type of object sending the event, 
        // and the event.
        String cursorEvent = String.Format("[{0}]: {1}", 
               sender.GetType().ToString(), "Cursor changed");
        // Record this event in the list view.
        this.cursorEventViewer.get_Items().Add(cursorEvent);
    } //testPanel_CursorChanged
} //Form1

下面的示例在窗体中以正常大小绘制指定的光标,在拉伸模式中以正常大小的两倍绘制。该示例假定在调用此方法时有可传入到此方法中的 FormCursor 对象。

Private Sub DrawCursorsOnForm(cursor As Cursor)
   ' If the form's cursor is not the Hand cursor and the 
   ' Current cursor is the Default, Draw the specified 
   ' cursor on the form in normal size and twice normal size. 
   If (Not Me.Cursor.Equals(Cursors.Hand)) And _
     Cursor.Current.Equals(Cursors.Default) Then

      ' Draw the cursor stretched.
      Dim graphics As Graphics = Me.CreateGraphics()
      Dim rectangle As New Rectangle(New Point(10, 10), _
        New Size(cursor.Size.Width * 2, cursor.Size.Height * 2))
      cursor.DrawStretched(graphics, rectangle)
     
      ' Draw the cursor in normal size.
      rectangle.Location = New Point(rectangle.Width + _
        rectangle.Location.X, rectangle.Height + rectangle.Location.Y)
      rectangle.Size = cursor.Size
      cursor.Draw(graphics, rectangle)

      ' Dispose of the cursor.
      cursor.Dispose()
   End If
End Sub
private void DrawCursorsOnForm(Cursor cursor)
{
   // If the form's cursor is not the Hand cursor and the 
   // Current cursor is the Default, Draw the specified 
   // cursor on the form in normal size and twice normal size.
   if(this.Cursor != Cursors.Hand & 
     Cursor.Current == Cursors.Default)
   {
      // Draw the cursor stretched.
      Graphics graphics = this.CreateGraphics();
      Rectangle rectangle = new Rectangle(
        new Point(10,10), new Size(cursor.Size.Width * 2, 
        cursor.Size.Height * 2));
      cursor.DrawStretched(graphics, rectangle);
        
      // Draw the cursor in normal size.
      rectangle.Location = new Point(
      rectangle.Width + rectangle.Location.X, 
        rectangle.Height + rectangle.Location.Y);
      rectangle.Size = cursor.Size;
      cursor.Draw(graphics, rectangle);

      // Dispose of the cursor.
      cursor.Dispose();
   }
}
void DrawCursorsOnForm( System::Windows::Forms::Cursor^ cursor )
{
   
   // If the form's cursor is not the Hand cursor and the
   // Current cursor is the Default, Draw the specified
   // cursor on the form in normal size and twice normal size.
   if ( this->Cursor != Cursors::Hand && System::Windows::Forms::Cursor::Current == Cursors::Default )
   {
      
      // Draw the cursor stretched.
      Graphics^ graphics = this->CreateGraphics();
      Rectangle rectangle = Rectangle(Point(10,10),System::Drawing::Size( cursor->Size.Width * 2, cursor->Size.Height * 2 ));
      cursor->DrawStretched( graphics, rectangle );
      
      // Draw the cursor in normal size.
      rectangle.Location = Point(rectangle.Width + rectangle.Location.X,rectangle.Height + rectangle.Location.Y);
      rectangle.Size = cursor->Size;
      cursor->Draw( graphics, rectangle );
      
      // Dispose of the cursor.
      delete cursor;
   }
}
private void DrawCursorsOnForm(Cursor cursor)
{
    // If the form's cursor is not the Hand cursor and the 
    // Current cursor is the Default, Draw the specified 
    // cursor on the form in normal size and twice normal size.
        if (!(this.get_Cursor().Equals(Cursors.get_Hand())) 
            & get_Cursor().get_Current().Equals(Cursors.get_Default())) {
        // Draw the cursor stretched.
        Graphics graphics = this.CreateGraphics();
        Rectangle rectangle = new Rectangle(new Point(10, 10), 
            new Size(cursor.get_Size().get_Width() * 2, 
            cursor.get_Size().get_Height() * 2));
        cursor.DrawStretched(graphics, rectangle);
        // Draw the cursor in normal size.
        rectangle.set_Location(new Point(rectangle.get_Width() 
            + rectangle.get_Location().get_X(), rectangle.get_Height() 
            + rectangle.get_Location().get_Y()));
        rectangle.set_Size(cursor.get_Size());
        cursor.Draw(graphics, rectangle);
        // Dispose of the cursor.
        cursor.Dispose();
    }
} //DrawCursorsOnForm

继承层次结构

System.Object
  System.Windows.Forms.Cursors

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

Cursors 成员
System.Windows.Forms 命名空间
Cursor 类