Cursors 클래스

정의

Windows Forms 애플리케이션이 사용할 Cursor 개체의 컬렉션을 제공합니다.

public ref class Cursors sealed
public ref class Cursors abstract sealed
public sealed class Cursors
public static class Cursors
type Cursors = class
Public NotInheritable Class Cursors
Public Class Cursors
상속
Cursors

예제

다음 예제에서는 사용 하 여 마우스 커서를 변경 하는 방법을 보여 줍니다 합니다 Control.Cursor 속성을 Cursor 클래스 및 Cursors 클래스. 이 예제에서는 포함 된 폼을 만듭니다는 ComboBox 컨트롤을 Panel 컨트롤 및 ListView 컨트롤입니다. 합니다 ComboBox 에서 제공 하는 모든 커서를 포함 합니다 Cursors 클래스입니다. 사용자가에 마우스 커서를 선택 하는 경우는 ComboBox, Control.Cursor 선택한 커서에 대 한 커서를 업데이트 하는 속성을 Panel. 합니다 ListView 때마다 업데이트 됩니다는 Control.CursorChanged 이벤트가 발생 합니다.

#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 );
}
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);
        }
    }
}
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

        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

        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
End Namespace 'MCursor

다음 예제에서는 크기의 두 배로 늘어난 모드로 보통 크기로 폼에서 지정된 된 커서를 그립니다. 이 예에서는 있다고 가정를 FormCursor 호출 될 때 메서드로 전달할 개체입니다.

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.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();
   }
}
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

설명

일부는 Cursor 이 클래스의 개체에서 설명 하는 것 보다 다른 모양을 걸릴 수 있습니다. 사용자가 운영 체제에서 마우스 포인터 설정을 조정 하 여 커서 모양을 변경할 수 있습니다. 패닝 및 이동 커서는 정적이 고 운영 체제에서 변경할 수 없습니다.

패닝 및 마우스 휠 조작 중 커서를 사용 하는 이동 합니다. 창을 스크롤할 수 있는 방향에 따라 커서가 변경 적절 한 이동 커서가 없습니다 휠을 클릭할 때입니다. 마우스를 이동 하는 대로 다음 커서 이동 적절 한 커서를 변경 합니다.

속성

AppStarting

애플리케이션이 시작될 때 나타나는 커서를 가져옵니다.

Arrow

화살표 커서를 가져옵니다.

Cross

십자형 커서를 가져옵니다.

Default

일반적으로 화살표 커서인 기본 커서를 가져옵니다.

Hand

일반적으로 웹 링크를 가리킬 때 사용되는 손 모양 커서를 가져옵니다.

Help

화살표와 물음표가 조합된 도움말 커서를 가져옵니다.

HSplit

마우스가 가로 분할 막대에 위치할 때 나타나는 커서를 가져옵니다.

IBeam

마우스를 클릭할 때 텍스트 커서가 나타나는 위치를 보여 주는 데 사용되는 I형 커서를 가져옵니다.

No

특정 영역이 현재 조작에 유효하지 않다는 것을 나타내는 커서를 가져옵니다.

NoMove2D

마우스는 이동하지 않지만 창이 가로와 세로 방향으로 스크롤할 수 있는 경우 휠 조작 중에 나타나는 커서를 가져옵니다.

NoMoveHoriz

마우스는 이동하지 않지만 창이 가로 방향으로 스크롤할 수 있는 경우 휠 조작 중에 나타나는 커서를 가져옵니다.

NoMoveVert

마우스는 이동하지 않지만 창이 세로 방향으로 스크롤할 수 있는 경우 휠 조작 중에 나타나는 커서를 가져옵니다.

PanEast

마우스가 이동하고 창은 오른쪽 가로 방향으로 스크롤하는 경우 휠 조작 중에 나타나는 커서를 가져옵니다.

PanNE

마우스가 이동하고 창은 오른쪽 위로 가로와 세로 방향으로 스크롤하는 경우 휠 조작 중에 나타나는 커서를 가져옵니다.

PanNorth

마우스가 이동하고 창은 위쪽 세로 방향으로 스크롤하는 경우 휠 조작 중에 나타나는 커서를 가져옵니다.

PanNW

마우스가 이동하고 창은 왼쪽 위로 가로와 세로 방향으로 스크롤하는 경우 휠 조작 중에 나타나는 커서를 가져옵니다.

PanSE

마우스가 이동하고 창은 오른쪽 아래로 가로와 세로 방향으로 스크롤하는 경우 휠 조작 중에 나타나는 커서를 가져옵니다.

PanSouth

마우스가 이동하고 창은 아래쪽 세로 방향으로 스크롤하는 경우 휠 조작 중에 나타나는 커서를 가져옵니다.

PanSW

마우스가 이동하고 창은 왼쪽 아래로 가로와 세로 방향으로 스크롤하는 경우 휠 조작 중에 나타나는 커서를 가져옵니다.

PanWest

마우스가 이동하고 창은 왼쪽 가로 방향으로 스크롤하는 경우 휠 조작 중에 나타나는 커서를 가져옵니다.

SizeAll

동서남북을 가리키는 네 개의 화살표로 구성된 십자형 크기 조정 커서를 가져옵니다.

SizeNESW

일자형 대각선(북동/남서) 크기 조정 커서를 가져옵니다.

SizeNS

일자형 세로(북/남) 크기 조정 커서를 가져옵니다.

SizeNWSE

일자형 대각선(북서/남동) 크기 조정 커서를 가져옵니다.

SizeWE

일자형 가로(서/동) 크기 조정 커서를 가져옵니다.

UpArrow

일반적으로 삽입 지점을 확인하는 데 사용되는 위쪽 화살표 커서를 가져옵니다.

VSplit

마우스가 세로 분할 막대에 위치할 때 나타나는 커서를 가져옵니다.

WaitCursor

일반적으로 모래 시계 모양인 대기 커서를 가져옵니다.

적용 대상

추가 정보