CURSORとは? わかりやすく解説

cursor

別表記:カーソル

「cursor」の意味・「cursor」とは

「cursor」とは、コンピュータの画面上で位置や選択を示すための視覚的なマーカーを指す。一般的には、マウスやトラックパッドの動きに連動して画面上を移動するポインター、またはテキスト入力時に次に文字が表示される位置を示す縦線を指すことが多い。

「cursor」の発音・読み方

「cursor」の発音は、IPA表記では /ˈkɝːrsər/ となる。これをカタカナ表記にすると「カーサー」となる。日本人が発音する際のカタカナ英語では「カーソル」となる。

「cursor」の定義を英語で解説

「cursor」は、英語で "a movable indicator on a computer screen identifying the point that will respond to input" と定義される。これは、「コンピュータ画面上の移動可能な指標で、入力に応答するポイントを識別するもの」という意味である。

「cursor」の類語

「cursor」の類語には、「pointer」や「indicator」などがある。これらはいずれも、何らかの位置や方向、状態を示すための視覚的なマーカーを指す言葉である。

「cursor」に関連する用語・表現

「cursor」に関連する用語や表現としては、「mouse cursor」、「text cursor」、「cursor movement」、「cursor position」などがある。「mouse cursor」はマウスによって操作されるカーソルを、「text cursor」はテキスト入力時のカーソルを指す。また、「cursor movement」はカーソルの移動を、「cursor position」はカーソルの位置を示す。

「cursor」の例文

1. Move the cursor to the right.(カーソルを右に移動させる。)
2. The cursor is blinking on the screen.(カーソルが画面上で点滅している。)
3. Click the left mouse button to position the cursor.(カーソルを配置するためにマウスの左ボタンをクリックする。)
4. The text cursor indicates where the next characters will be inserted.(テキストカーソルは次の文字が挿入される位置を示す。)
5. You can control the cursor with the arrow keys.(矢印キーでカーソルを操作できる。)
6. The cursor disappeared from the screen.(カーソルが画面から消えた。)
7. Drag the cursor across the text to select it.(テキストを選択するためにカーソルをドラッグする。)
8. The cursor movement is too fast.(カーソルの移動が速すぎる。)
9. The cursor position is at the end of the line.(カーソルの位置は行の末尾にある。)
10. The mouse cursor and the text cursor are different.(マウスカーソルとテキストカーソルは異なる。)

カーソル【cursor】

読み方:かーそる

1 計算尺・測量器などで、前後または左右に滑らせて目盛りを読み取る透明な小板。滑尺。遊標。

2 コンピューターのディスプレー上で、次の入力の位置を示す印。


カーソル

【英】cursor

カーソルとは、PCの画面上で入力が行われる位置を示すマークのことである。

グラフィカルユーザーインターフェース(GUI)上では、カーソルを操作する手段は主にマウスとキーボードがある。このうち、マウスの操作に従って画面上を動くカーソルは特にマウスカーソル(マウスポインタ)などと呼ばれることが多い。一般的には、マウスカーソルは普段は矢印の形をしており、カーソルの乗った場所によって両矢印や手のアイコンなどに表示が変化する。そのときのカーソルの形によって、できる操作が異なる。

また、ワープロソフトやテキストエディタなどで文字の入力位置を示すためのカーソルは、特にキャレットやアイビームなどと呼ばれることがある。WindowsやMacOSでは点滅する「I」字形の棒として示される。


Cursor クラス

メモ : このクラスは、.NET Framework version 2.0 で新しく追加されたものです。

Cursor は、キューのメッセージを読み取るときに、MessageQueue 内の特定の場所を維持するために使用されます。

名前空間: System.Messaging
アセンブリ: System.Messaging (system.messaging.dll 内)
構文構文

解説解説
継承階層継承階層
System.Object
  System.Messaging.Cursor
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Cursor クラス

マウス ポインタの描画に使用されるイメージを表します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

<SerializableAttribute> _
Public NotInheritable Class
 Cursor
    Implements IDisposable, ISerializable
[SerializableAttribute] 
public sealed class Cursor : IDisposable, ISerializable
[SerializableAttribute] 
public ref class Cursor sealed : IDisposable,
 ISerializable
/** @attribute SerializableAttribute() */ 
public final class Cursor implements IDisposable,
 ISerializable
SerializableAttribute 
public final class Cursor implements IDisposable,
 ISerializable
解説解説

カーソルは、画面に表示される小さなピクチャです。画面上のカーソルの位置は、マウス、ペン、トラックボールなどのポインティング デバイスによって制御されます。ユーザーがポインティング デバイスを動かすと、その動きに応じ、オペレーティング システムによりカーソルが移動されます。

カーソルの形を変えることで、マウスの操作目的をユーザーに示します。たとえば、テキストを編集または選択するときは、通常、Cursors.IBeam カーソルが表示されます。プロセスが現在実行中であることを示すには、通常、待機カーソルが使用されます。ユーザーを待機させる可能性のあるプロセスの例には、ファイルのオープンや保存、またはコントロール (DataGrid、ListBox、または TreeView) への大量のデータの格納があります。

Control クラスから派生するすべてのコントロールには、Cursor プロパティがあります。マウス ポインタによって表示されるカーソルをコントロールの範囲内で変更するには、Cursor をコントロールの Cursor プロパティに割り当てます。また、Cursor を Current プロパティに割り当て、アプリケーション レベルでカーソルを表示することもできます。たとえば、アプリケーションでテキストファイルを編集する場合は、Current プロパティを Cursors.WaitCursor に設定し、ファイルの読み込みまたは保存中にマウス イベントが処理されないように、アプリケーション上に待機カーソルを表示します。このプロセスが完了すると、アプリケーションで各コントロールの種類に応じた適切なカーソルを表示するために、Current プロパティを Cursors.Default に設定します。

メモメモ

Current プロパティを Cursors.Default カーソルにリセットする前に Application.DoEvents を呼び出すと、アプリケーションがマウス イベントの待機を再開し、アプリケーションの各コントロールの適切な Cursor の表示を再開します。

カーソル オブジェクトは、既存の Cursor のハンドル、標準 Cursor ファイル、リソース、データ ストリームなど、複数のソースから作成できます。

カーソルとして使用するイメージが小さすぎる場合は、DrawStretched メソッドを使用して、イメージを強制的にカーソルの境界まで拡大できます。Hide メソッドを呼び出してカーソルを一時的に非表示にしたり、Show メソッドを呼び出して元に戻したりできます。

使用例使用例

カスタム カーソルの使用方法を示すフォームを表示するコード例を次に示します。カスタム Cursor は、アプリケーションのリソース ファイルに組み込まれています。この例では、MyCursor.cur という名前のカーソル ファイルに、カーソルが格納されている必要があります。コマンド ラインでこの例をコンパイルするには、フラグ /res:MyCursor.Cur, CustomCursor.MyCursor.Cur を格納します。

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

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

      Public Sub New()

         Me.ClientSize = New System.Drawing.Size(292,
 266)
         Me.Text = "Cursor Example"
         
         ' Looks namespace.MyCursor.cur in the assemblies manifest.
         
         ' The following generates a cursor from an embedded resource.
         ' To add a custom cursor, create or use an existing 16x16 bitmap
         '        1. Add a new cursor file to your project: 
         '                File->Add New Item->Local Project Items->Cursor
 File
         '        2. Select 16x16 image type:
         '                Image->Current Icon Image Types->16x16
         ' --- To make the custom cursor an embedded resource  ---
         ' In Visual Studio:
         '        1. Select the cursor file in the Solution Explorer
         '        2. Choose View->Properties.
         '        3. In the properties window switch "Build Action"
 to "Embedded"
         ' On the command line:
         '        Add the following flag:
         '            /res:CursorFileName.Cur,Namespace.CursorFileName.Cur
         '
         ' The following line uses the namespace from the passed-in
 type
         ' and looks for CustomCursor.MyCursor.Cur in the assemblies
 manifest.
     ' NOTE: The cursor name is acase sensitive.        
     
         Me.Cursor = New Cursor(Me.GetType(),
 "MyCursor.Cur") 
      End Sub 'New       
   End Class 'Form1
End Namespace 'CustomCursor
using System;
using System.Drawing;
using System.Windows.Forms;

namespace CustomCursor
{
    public class Form1 : System.Windows.Forms.Form
    {
        [STAThread]
        static void Main() 
        {
            Application.Run(new Form1());
        }

        public Form1()
        {
            this.ClientSize = new System.Drawing.Size(292,
 266);
            this.Text = "Cursor Example";
            
            // The following generates a cursor from an embedded resource.
            
            // To add a custom cursor, create or use an existing 16x16
 bitmap
            //        1. Add a new cursor file to your project: 
            //                File->Add New Item->Local Project
 Items->Cursor File
            //        2. Select 16x16 image type:
            //                Image->Current Icon Image Types->16x16

            // --- To make the custom cursor an embedded resource  ---
            
            // In Visual Studio:
            //        1. Select the cursor file in the Solution Explorer
            //        2. Choose View->Properties.
            //        3. In the properties window switch "Build
 Action" to "Embedded"

            // On the command line:
            //        Add the following flag:
            //            /res:CursorFileName.Cur,Namespace.CursorFileName.Cur
            //        
            //        Where "Namespace" is the namespace in
 which you want to use the cursor
            //        and   "CursorFileName.Cur" is the cursor
 filename.

            // The following line uses the namespace from the passed-in
 type
            // and looks for CustomCursor.MyCursor.Cur in the assemblies
 manifest.
        // NOTE: The cursor name is acase sensitive.
            this.Cursor = new Cursor(GetType(),
 "MyCursor.Cur");  
           
        }
    }
}
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

namespace CustomCursor
{
   public ref class Form1: public
 System::Windows::Forms::Form
   {
   public:
      Form1()
      {
         this->ClientSize = System::Drawing::Size( 292, 266
 );
         this->Text = "Cursor Example";
         
         // The following generates a cursor from an embedded resource.
         // To add a custom cursor, create or use an existing 16x16
 bitmap
         //        1. Add a new cursor file to your project:
         //                File->Add New Item->Local Project Items->Cursor
 File
         //        2. Select 16x16 image type:
         //                Image->Current Icon Image Types->16x16
         // --- To make the custom cursor an embedded resource  ---
         // In Visual Studio:
         //        1. Select the cursor file in the Solution Explorer
         //        2. Choose View->Properties.
         //        3. In the properties window switch "Build Action"
 to "Embedded"
         // On the command line:
         //        Add the following flag:
         //            /res:CursorFileName.Cur, Namespace.CursorFileName.Cur
         //
         //        Where "Namespace" is the namespace in which
 you want to use the cursor
         //        and   "CursorFileName.Cur" is the cursor
 filename.
         // The following line uses the namespace from the passed-in
 type
         // and looks for CustomCursor.MyCursor.Cur in the assemblies
 manifest.
         // NOTE: The cursor name is case sensitive.
         this->Cursor = gcnew System::Windows::Forms::Cursor(
 GetType(),"MyCursor.Cur" );
      }

   };

}


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

package CustomCursor;

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

public class Form1 extends System.Windows.Forms.Form
{
    /** @attribute STAThread()
     */
    public static void main(String[]
 args)
    {
        Application.Run(new Form1());
    } //main

    public Form1()
    {
        this.set_ClientSize(new System.Drawing.Size(292,
 266));
        this.set_Text("Cursor Example");
        // The following generates a cursor from an embedded resource.
        // To add a custom cursor, create or use an existing 16x16 bitmap
        //        1. Add a new cursor file to your project: 
        //                File->Add New Item->Local Project Items->Cursor
 File
        //        2. Select 16x16 image type:
        //                Image->Current Icon Image Types->16x16
        // --- To make the custom cursor an embedded resource  ---
        // In Visual Studio:
        //        1. Select the cursor file in the Solution Explorer
        //        2. Choose View->Properties.
        //        3. In the properties window switch "Build Action"
 to "Embedded"
        // On the command line:
        //        Add the following flag:
        //            /res:CursorFileName.Cur,Namespace.CursorFileName.Cur
        //        
        //        Where "Namespace" is the namespace in which
 you want to use
        //        the cursor and   "CursorFileName.Cur" is
 the cursor filename.
        // The following line uses the namespace from the passed-in
 type
        // and looks for CustomCursor.MyCursor.Cur in the assemblies
 manifest.
        // NOTE: The cursor name is acase sensitive.
        this.set_Cursor(new Cursor(GetType(),
 "MyCursor.Cur"));
    } //Form1 
} //Form1

TreeView コントロールに顧客情報を表示するコード例を次に示します。ルート ツリー ノードに顧客名が表示され、各顧客に割り当てられた発注番号が子ツリー ノードに表示されます。この例では、1,000 人の顧客が表示され、顧客ごとに 15 の発注内容が示されます。BeginUpdate メソッドと EndUpdate メソッドを使用すると、TreeView は再描画されません。TreeView が TreeNode オブジェクトを作成して描画する間、待機 Cursor が表示されます。この例では、アプリケーション ディレクトリに MyWait.cur という名前のカーソル ファイルが保存されている必要があります。また、Order オブジェクトのコレクションを保持する Customer オブジェクトが存在し、Form 上に TreeView コントロールのインスタンスが作成されている必要もあります。

' Create a new ArrayList to hold the Customer objects.
Private customerArray As New
 ArrayList()

Private Sub FillMyTreeView()
   ' Add customers to the ArrayList of Customer objects.
   Dim x As Integer
   For x = 0 To 999
      customerArray.Add(New Customer("Customer"
 + x.ToString()))
   Next x

   ' Add orders to each Customer object in the ArrayList.
   Dim customer1 As Customer
   For Each customer1 In
 customerArray
      Dim y As Integer
      For y = 0 To 14
         customer1.CustomerOrders.Add(New Order("Order"
 + y.ToString()))
      Next y
   Next customer1

   ' Display a wait cursor while the TreeNodes are being created.
   Cursor.Current = New Cursor("MyWait.cur")

   ' Suppress repainting the TreeView until all the objects have been
 created.
   treeView1.BeginUpdate()

   ' Clear the TreeView each time the method is called.
   treeView1.Nodes.Clear()

   ' Add a root TreeNode for each Customer object in the ArrayList.
   Dim customer2 As Customer
   For Each customer2 In
 customerArray
      treeView1.Nodes.Add(New TreeNode(customer2.CustomerName))

      ' Add a child TreeNode for each Order object in the current Customer
 object.
      Dim order1 As Order
      For Each order1 In
 customer2.CustomerOrders
         treeView1.Nodes(customerArray.IndexOf(customer2)).Nodes.Add( _
    New TreeNode(customer2.CustomerName + "."
 + order1.OrderID))
      Next order1
   Next customer2

   ' Reset the cursor to the default for all controls.
   Cursor.Current = System.Windows.Forms.Cursors.Default

   ' Begin repainting the TreeView.
   treeView1.EndUpdate()
End Sub 'FillMyTreeView
// Create a new ArrayList to hold the Customer objects.
private ArrayList customerArray = new ArrayList();
 

private void FillMyTreeView()
{
   // Add customers to the ArrayList of Customer objects.
   for(int x=0; x<1000; x++)
   {
      customerArray.Add(new Customer("Customer" + x.ToString()));
   }

   // Add orders to each Customer object in the ArrayList.
   foreach(Customer customer1 in customerArray)
   {
      for(int y=0; y<15; y++)
      {
         customer1.CustomerOrders.Add(new Order("Order"
 + y.ToString()));    
      }
   }

   // Display a wait cursor while the TreeNodes are being created.
   Cursor.Current = new Cursor("MyWait.cur");
        
   // Suppress repainting the TreeView until all the objects have been
 created.
   treeView1.BeginUpdate();

   // Clear the TreeView each time the method is called.
   treeView1.Nodes.Clear();

   // Add a root TreeNode for each Customer object in the ArrayList.
   foreach(Customer customer2 in customerArray)
   {
      treeView1.Nodes.Add(new TreeNode(customer2.CustomerName));
          
      // Add a child treenode for each Order object in the current Customer
 object.
      foreach(Order order1 in customer2.CustomerOrders)
      {
         treeView1.Nodes[customerArray.IndexOf(customer2)].Nodes.Add(
           new TreeNode(customer2.CustomerName + "."
 + order1.OrderID));
      }
   }

   // Reset the cursor to the default for all controls.
   Cursor.Current = Cursors.Default;

   // Begin repainting the TreeView.
   treeView1.EndUpdate();
}
void FillMyTreeView()
{
   // Add customers to the ArrayList of Customer objects.
   for ( int x = 0; x < 1000; x++ )
   {
      customerArray->Add( gcnew Customer( "Customer " + x ) );
   }
   
   // Add orders to each Customer object in the ArrayList.
   IEnumerator^ myEnum = customerArray->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      Customer^ customer1 = safe_cast<Customer^>(myEnum->Current);
      for ( int y = 0; y < 15; y++ )
      {
         customer1->CustomerOrders->Add( gcnew Order( "Order " +
 y ) );
      }
   }

   // Display a wait cursor while the TreeNodes are being created.
   ::Cursor::Current = gcnew System::Windows::Forms::Cursor( "MyWait.cur"
 );
   
   // Suppress repainting the TreeView until all the objects have been
 created.
   treeView1->BeginUpdate();
   
   // Clear the TreeView each time the method is called.
   treeView1->Nodes->Clear();
   
   // Add a root TreeNode for each Customer object in the ArrayList.
   while ( myEnum->MoveNext() )
   {
      Customer^ customer2 = safe_cast<Customer^>(myEnum->Current);
      treeView1->Nodes->Add( gcnew TreeNode( customer2->CustomerName ) );
      
      // Add a child treenode for each Order object in the current Customer
 object.
      IEnumerator^ myEnum = customer2->CustomerOrders->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         Order^ order1 = safe_cast<Order^>(myEnum->Current);
         treeView1->Nodes[ customerArray->IndexOf( customer2 ) ]->Nodes->Add(
 gcnew TreeNode( customer2->CustomerName + "." + order1->OrderID
 ) );
      }
   }
   
   // Reset the cursor to the default for all controls.
   ::Cursor::Current = Cursors::Default;
   
   // Begin repainting the TreeView.
   treeView1->EndUpdate();
}
// Create a new ArrayList to hold the Customer objects.
private ArrayList customerArray = new ArrayList();

private void FillMyTreeView()
{
    // Add customers to the ArrayList of Customer objects.
    for (int x = 0; x < 1000; x++) {
        customerArray.Add(new Customer("Customer"
            + ((Int32)x).ToString()));
    }
    // Add orders to each Customer object in the ArrayList.
    for (int iCtr = 0; iCtr < customerArray.get_Count();
 iCtr++) {
        Customer customer1 = (Customer)customerArray.get_Item(iCtr);
        for (int y = 0; y < 15; y++) {
            customer1.get_CustomerOrders().Add(new Order("Order"
                + ((Int32)y).ToString()));
        }
    }
    // Display a wait cursor while the TreeNodes are being created.
    get_Cursor().set_Current(new Cursor("MyWait.cur"));
    // Suppress repainting the TreeView until all the objects have
    // been created.
    treeView1.BeginUpdate();
    // Clear the TreeView each time the method is called.
    treeView1.get_Nodes().Clear();
    // Add a root TreeNode for each Customer object in the ArrayList.
    for (int iCtr1 = 0; iCtr1 < customerArray.get_Count();
 iCtr1++) {
        Customer customer2 = (Customer)customerArray.get_Item(iCtr1);
        treeView1.get_Nodes().Add(new TreeNode(customer2.get_CustomerName()));
        // Add a child treenode for each Order object in the current
        // Customer object.
        for (int iCtr2 = 0; iCtr2 < customer2.get_CustomerOrders().
            get_Count(); iCtr2++) {
            Order order1 = (Order)customer2.get_CustomerOrders().
                get_Item(iCtr2);
            treeView1.get_Nodes().
                get_Item(customerArray.IndexOf(customer2)).get_Nodes().
                Add(new TreeNode(customer2.get_CustomerName()
 + "."
                + order1.get_OrderID()));
        }
    }
    // Reset the cursor to the default for all controls.
    get_Cursor().set_Current(Cursors.get_Default());
    // Begin repainting the TreeView.
    treeView1.EndUpdate();
} //FillMyTreeView
継承階層継承階層
System.Object
  System.Windows.Forms.Cursor
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Cursor コンストラクタ (Stream)

指定したデータ ストリームで Cursor クラスの新しいインスタンスを初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説
使用例使用例

OpenFileDialog の OpenFile メソッドによって作成された Stream からカーソルを読み込むコード例を次に示します。このメソッドが呼び出されると、OpenFileDialog がユーザーに表示されます。.cur ファイルを選択してこのダイアログを閉じると、このファイルが開かれ、返された Stream を使用して Cursor が作成されます。

Private Sub SetCursor()
   ' Display an OpenFileDialog so the user can select a Cursor.
   Dim openFileDialog1 As New
 OpenFileDialog()
   openFileDialog1.Filter = "Cursor Files|*.cur"
   openFileDialog1.Title = "Select a Cursor File"
   openFileDialog1.ShowDialog()
         
   ' If a .cur file was selected, open it.
   If openFileDialog1.FileName <> ""
 Then
      ' Assign the cursor in the stream to the form's Cursor property.
      Me.Cursor = New Cursor(openFileDialog1.OpenFile())
   End If
End Sub     
private void SetCursor()
{
   // Display an OpenFileDialog so the user can select a cursor.
   OpenFileDialog openFileDialog1 = new OpenFileDialog();
   openFileDialog1.Filter = "Cursor Files|*.cur";
   openFileDialog1.Title = "Select a Cursor File";
   openFileDialog1.ShowDialog();

   // If a .cur file was selected, open it.
   if(openFileDialog1.FileName != "")
   {
      // Assign the cursor in the stream to the form's Cursor property.
      this.Cursor = new Cursor(openFileDialog1.OpenFile());
   }
}
private:
   void SetCursor()
   {
      // Display an OpenFileDialog so the user can select a cursor.
      OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
      openFileDialog1->Filter = "Cursor Files|*.cur";
      openFileDialog1->Title = "Select a Cursor File";
      openFileDialog1->ShowDialog();

      // If a .cur file was selected, open it.
      if (  !openFileDialog1->FileName->Equals( ""
 ) )
      {
         // Assign the cursor in the stream to the form's Cursor property.
         this->Cursor = gcnew System::Windows::Forms::Cursor(
 openFileDialog1->OpenFile() );
      }
   }
private void SetCursor()
{
    // Display an OpenFileDialog so the user can select a cursor.
    OpenFileDialog openFileDialog1 = new OpenFileDialog();

    openFileDialog1.set_Filter("Cursor Files|*.cur");
    openFileDialog1.set_Title("Select a Cursor File");
    openFileDialog1.ShowDialog();

    // If a .cur file was selected, open it.
    if (!(openFileDialog1.get_FileName().Equals("")))
 {
        // Assign the cursor in the stream to the form's Cursor property.
        this.set_Cursor(new Cursor(openFileDialog1.OpenFile()));
    }
} //SetCursor
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Cursor コンストラクタ (IntPtr)

指定した Windows ハンドルで Cursor クラスの新しいインスタンスを初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub New ( _
    handle As IntPtr _
)
public Cursor (
    IntPtr handle
)
public:
Cursor (
    IntPtr handle
)
public Cursor (
    IntPtr handle
)
public function Cursor (
    handle : IntPtr
)

パラメータ

handle

作成するカーソルの Windows ハンドルを表す IntPtr。

例外例外
例外の種類条件

ArgumentException

handle が IntPtr.Zero です。

解説解説
使用例使用例

Current のカーソルの Handle からカーソルを作成し、その位置とクリッピング四角形を変更するコード例を次に示します。結果として、カーソルはコード実行時の位置から上に 50 ピクセル、左に 50 ピクセルの場所に移動します。さらに、カーソルのクリッピング四角形がフォームの境界に変更されます。既定では、これはユーザーの画面全体です。この例では、Form、およびクリックされたときにこのコードを呼び出す Button が存在する必要があります。

Private Sub MoveCursor()
   ' If the form's cursor is not the Default cursor,
   ' set the Current cursor, move the cursor's Position,
   ' and set its clipping rectangle to the form. 
   If Not Me.Cursor.Equals(Cursors.Default)
 Then
      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 If
End Sub
private void MoveCursor()
{
   // If the form's cursor is not the Default cursor,
   // set the Current cursor, move the cursor's Position,
   // and set its clipping rectangle to the form. 
   if(!this.Cursor.Equals(Cursors.Default))
   {
   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);
   }
}
void MoveCursor()
{
   
   // If the form's cursor is not the Default cursor,
   // set the Current cursor, move the cursor's Position,
   // and set its clipping rectangle to the form.
   if (  !this->Cursor->Equals( Cursors::Default
 ) )
   {
      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()
{
    // If the form's cursor is not the Default cursor,
    // set the Current cursor, move the cursor's Position,
    // and set its clipping rectangle to the form. 
    if (!(this.get_Cursor().Equals(Cursors.get_Default())))
 {
        this.set_Cursor(new Cursor(get_Cursor().get_Current().
            get_Handle()));
        Cursor.set_Position(new Point(get_Cursor().get_Position().
            get_X() - 50, get_Cursor().get_Position().get_Y() - 50));
        get_Cursor().set_Clip(new Rectangle(this.get_Location(),
 
            this.get_Size()));
    }
} //MoveCursor
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Cursor コンストラクタ (Type, String)

指定したリソースの種類を使用して、指定したリソースで Cursor クラスの新しいインスタンスを初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説

アプリケーション内にリソースとしてカーソルを埋め込む方法を次の例に示します。リソースを埋め込むには、リソース名とアセンブリの完全パスをコンマで区切って参照を指定します。埋め込まれたリソースからカーソルを読み込む方法については、例のセクションを参照してください。

 Using the C# compiler:
 csc /resource:"MyWaitCursor.cur","MyCursors.MyWaitCursor.cur" MyCursor.cs
 Using the Visual Basic compiler:
 vbc /resource:"MyWaitCursor.cur","MyCursors.MyWaitCursor.cur" MyCursor.vb
メモメモ

リソースを参照するとき (コンパイル時およびコード内での参照時) は、C# コンパイラおよび Visual Basic コンパイラの両方で大文字と小文字が区別されます。

使用例使用例

Cursor コンストラクタを使用して、カスタム カーソルの使用方法を示すフォームを表示するコード例を次に示します。カスタム Cursor は、アプリケーションのリソース ファイルに組み込まれています。この例では、MyCursor.cur という名前のカーソル ファイルに、カーソルが格納されている必要があります。コマンド ラインでこの例をコンパイルするには、フラグ /res:MyCursor.Cur, CustomCursor.MyCursor.Cur を格納します。

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

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

      Public Sub New()

         Me.ClientSize = New System.Drawing.Size(292,
 266)
         Me.Text = "Cursor Example"
         
         ' Looks namespace.MyCursor.cur in the assemblies manifest.
         
         ' The following generates a cursor from an embedded resource.
         ' To add a custom cursor, create or use an existing 16x16 bitmap
         '        1. Add a new cursor file to your project: 
         '                File->Add New Item->Local Project Items->Cursor
 File
         '        2. Select 16x16 image type:
         '                Image->Current Icon Image Types->16x16
         ' --- To make the custom cursor an embedded resource  ---
         ' In Visual Studio:
         '        1. Select the cursor file in the Solution Explorer
         '        2. Choose View->Properties.
         '        3. In the properties window switch "Build Action"
 to "Embedded"
         ' On the command line:
         '        Add the following flag:
         '            /res:CursorFileName.Cur,Namespace.CursorFileName.Cur
         '
         ' The following line uses the namespace from the passed-in
 type
         ' and looks for CustomCursor.MyCursor.Cur in the assemblies
 manifest.
     ' NOTE: The cursor name is acase sensitive.        
     
         Me.Cursor = New Cursor(Me.GetType(),
 "MyCursor.Cur") 
      End Sub 'New       
   End Class 'Form1
End Namespace 'CustomCursor
using System;
using System.Drawing;
using System.Windows.Forms;

namespace CustomCursor
{
    public class Form1 : System.Windows.Forms.Form
    {
        [STAThread]
        static void Main() 
        {
            Application.Run(new Form1());
        }

        public Form1()
        {
            this.ClientSize = new System.Drawing.Size(292,
 266);
            this.Text = "Cursor Example";
            
            // The following generates a cursor from an embedded resource.
            
            // To add a custom cursor, create or use an existing 16x16
 bitmap
            //        1. Add a new cursor file to your project: 
            //                File->Add New Item->Local Project
 Items->Cursor File
            //        2. Select 16x16 image type:
            //                Image->Current Icon Image Types->16x16

            // --- To make the custom cursor an embedded resource  ---
            
            // In Visual Studio:
            //        1. Select the cursor file in the Solution Explorer
            //        2. Choose View->Properties.
            //        3. In the properties window switch "Build
 Action" to "Embedded"

            // On the command line:
            //        Add the following flag:
            //            /res:CursorFileName.Cur,Namespace.CursorFileName.Cur
            //        
            //        Where "Namespace" is the namespace in
 which you want to use the cursor
            //        and   "CursorFileName.Cur" is the cursor
 filename.

            // The following line uses the namespace from the passed-in
 type
            // and looks for CustomCursor.MyCursor.Cur in the assemblies
 manifest.
        // NOTE: The cursor name is acase sensitive.
            this.Cursor = new Cursor(GetType(),
 "MyCursor.Cur");  
           
        }
    }
}
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

namespace CustomCursor
{
   public ref class Form1: public
 System::Windows::Forms::Form
   {
   public:
      Form1()
      {
         this->ClientSize = System::Drawing::Size( 292, 266
 );
         this->Text = "Cursor Example";
         
         // The following generates a cursor from an embedded resource.
         // To add a custom cursor, create or use an existing 16x16
 bitmap
         //        1. Add a new cursor file to your project:
         //                File->Add New Item->Local Project Items->Cursor
 File
         //        2. Select 16x16 image type:
         //                Image->Current Icon Image Types->16x16
         // --- To make the custom cursor an embedded resource  ---
         // In Visual Studio:
         //        1. Select the cursor file in the Solution Explorer
         //        2. Choose View->Properties.
         //        3. In the properties window switch "Build Action"
 to "Embedded"
         // On the command line:
         //        Add the following flag:
         //            /res:CursorFileName.Cur, Namespace.CursorFileName.Cur
         //
         //        Where "Namespace" is the namespace in which
 you want to use the cursor
         //        and   "CursorFileName.Cur" is the cursor
 filename.
         // The following line uses the namespace from the passed-in
 type
         // and looks for CustomCursor.MyCursor.Cur in the assemblies
 manifest.
         // NOTE: The cursor name is case sensitive.
         this->Cursor = gcnew System::Windows::Forms::Cursor(
 GetType(),"MyCursor.Cur" );
      }

   };

}


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

package CustomCursor;

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

public class Form1 extends System.Windows.Forms.Form
{
    /** @attribute STAThread()
     */
    public static void main(String[]
 args)
    {
        Application.Run(new Form1());
    } //main

    public Form1()
    {
        this.set_ClientSize(new System.Drawing.Size(292,
 266));
        this.set_Text("Cursor Example");
        // The following generates a cursor from an embedded resource.
        // To add a custom cursor, create or use an existing 16x16 bitmap
        //        1. Add a new cursor file to your project: 
        //                File->Add New Item->Local Project Items->Cursor
 File
        //        2. Select 16x16 image type:
        //                Image->Current Icon Image Types->16x16
        // --- To make the custom cursor an embedded resource  ---
        // In Visual Studio:
        //        1. Select the cursor file in the Solution Explorer
        //        2. Choose View->Properties.
        //        3. In the properties window switch "Build Action"
 to "Embedded"
        // On the command line:
        //        Add the following flag:
        //            /res:CursorFileName.Cur,Namespace.CursorFileName.Cur
        //        
        //        Where "Namespace" is the namespace in which
 you want to use
        //        the cursor and   "CursorFileName.Cur" is
 the cursor filename.
        // The following line uses the namespace from the passed-in
 type
        // and looks for CustomCursor.MyCursor.Cur in the assemblies
 manifest.
        // NOTE: The cursor name is acase sensitive.
        this.set_Cursor(new Cursor(GetType(),
 "MyCursor.Cur"));
    } //Form1 
} //Form1
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Cursor コンストラクタ (String)

指定したファイルで Cursor クラスの新しいインスタンスを初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説
使用例使用例

TreeView コントロールに顧客情報を表示するコード例を次に示します。ルート ツリー ノードに顧客名が表示され、各顧客に割り当てられた発注番号が子ツリー ノードに表示されます。この例では、1,000 人の顧客が表示され、顧客ごとに 15 の発注内容が示されます。BeginUpdate メソッドと EndUpdate メソッドを使用すると、TreeView は再描画されません。TreeView が TreeNode オブジェクトを作成して描画する間、待機 Cursor が表示されます。この例では、Order オブジェクトのコレクションを保持できる Customer オブジェクトが存在する必要があります。また、TreeView コントロールのインスタンスが Form 上に作成されている必要もあります。

' Create a new ArrayList to hold the Customer objects.
Private customerArray As New
 ArrayList()

Private Sub FillMyTreeView()
   ' Add customers to the ArrayList of Customer objects.
   Dim x As Integer
   For x = 0 To 999
      customerArray.Add(New Customer("Customer"
 + x.ToString()))
   Next x

   ' Add orders to each Customer object in the ArrayList.
   Dim customer1 As Customer
   For Each customer1 In
 customerArray
      Dim y As Integer
      For y = 0 To 14
         customer1.CustomerOrders.Add(New Order("Order"
 + y.ToString()))
      Next y
   Next customer1

   ' Display a wait cursor while the TreeNodes are being created.
   Cursor.Current = New Cursor("MyWait.cur")

   ' Suppress repainting the TreeView until all the objects have been
 created.
   treeView1.BeginUpdate()

   ' Clear the TreeView each time the method is called.
   treeView1.Nodes.Clear()

   ' Add a root TreeNode for each Customer object in the ArrayList.
   Dim customer2 As Customer
   For Each customer2 In
 customerArray
      treeView1.Nodes.Add(New TreeNode(customer2.CustomerName))

      ' Add a child TreeNode for each Order object in the current Customer
 object.
      Dim order1 As Order
      For Each order1 In
 customer2.CustomerOrders
         treeView1.Nodes(customerArray.IndexOf(customer2)).Nodes.Add( _
    New TreeNode(customer2.CustomerName + "."
 + order1.OrderID))
      Next order1
   Next customer2

   ' Reset the cursor to the default for all controls.
   Cursor.Current = System.Windows.Forms.Cursors.Default

   ' Begin repainting the TreeView.
   treeView1.EndUpdate()
End Sub 'FillMyTreeView
// Create a new ArrayList to hold the Customer objects.
private ArrayList customerArray = new ArrayList();
 

private void FillMyTreeView()
{
   // Add customers to the ArrayList of Customer objects.
   for(int x=0; x<1000; x++)
   {
      customerArray.Add(new Customer("Customer" + x.ToString()));
   }

   // Add orders to each Customer object in the ArrayList.
   foreach(Customer customer1 in customerArray)
   {
      for(int y=0; y<15; y++)
      {
         customer1.CustomerOrders.Add(new Order("Order"
 + y.ToString()));    
      }
   }

   // Display a wait cursor while the TreeNodes are being created.
   Cursor.Current = new Cursor("MyWait.cur");
        
   // Suppress repainting the TreeView until all the objects have been
 created.
   treeView1.BeginUpdate();

   // Clear the TreeView each time the method is called.
   treeView1.Nodes.Clear();

   // Add a root TreeNode for each Customer object in the ArrayList.
   foreach(Customer customer2 in customerArray)
   {
      treeView1.Nodes.Add(new TreeNode(customer2.CustomerName));
          
      // Add a child treenode for each Order object in the current Customer
 object.
      foreach(Order order1 in customer2.CustomerOrders)
      {
         treeView1.Nodes[customerArray.IndexOf(customer2)].Nodes.Add(
           new TreeNode(customer2.CustomerName + "."
 + order1.OrderID));
      }
   }

   // Reset the cursor to the default for all controls.
   Cursor.Current = Cursors.Default;

   // Begin repainting the TreeView.
   treeView1.EndUpdate();
}
void FillMyTreeView()
{
   // Add customers to the ArrayList of Customer objects.
   for ( int x = 0; x < 1000; x++ )
   {
      customerArray->Add( gcnew Customer( "Customer " + x ) );
   }
   
   // Add orders to each Customer object in the ArrayList.
   IEnumerator^ myEnum = customerArray->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      Customer^ customer1 = safe_cast<Customer^>(myEnum->Current);
      for ( int y = 0; y < 15; y++ )
      {
         customer1->CustomerOrders->Add( gcnew Order( "Order " +
 y ) );
      }
   }

   // Display a wait cursor while the TreeNodes are being created.
   ::Cursor::Current = gcnew System::Windows::Forms::Cursor( "MyWait.cur"
 );
   
   // Suppress repainting the TreeView until all the objects have been
 created.
   treeView1->BeginUpdate();
   
   // Clear the TreeView each time the method is called.
   treeView1->Nodes->Clear();
   
   // Add a root TreeNode for each Customer object in the ArrayList.
   while ( myEnum->MoveNext() )
   {
      Customer^ customer2 = safe_cast<Customer^>(myEnum->Current);
      treeView1->Nodes->Add( gcnew TreeNode( customer2->CustomerName ) );
      
      // Add a child treenode for each Order object in the current Customer
 object.
      IEnumerator^ myEnum = customer2->CustomerOrders->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         Order^ order1 = safe_cast<Order^>(myEnum->Current);
         treeView1->Nodes[ customerArray->IndexOf( customer2 ) ]->Nodes->Add(
 gcnew TreeNode( customer2->CustomerName + "." + order1->OrderID
 ) );
      }
   }
   
   // Reset the cursor to the default for all controls.
   ::Cursor::Current = Cursors::Default;
   
   // Begin repainting the TreeView.
   treeView1->EndUpdate();
}
// Create a new ArrayList to hold the Customer objects.
private ArrayList customerArray = new ArrayList();

private void FillMyTreeView()
{
    // Add customers to the ArrayList of Customer objects.
    for (int x = 0; x < 1000; x++) {
        customerArray.Add(new Customer("Customer"
            + ((Int32)x).ToString()));
    }
    // Add orders to each Customer object in the ArrayList.
    for (int iCtr = 0; iCtr < customerArray.get_Count();
 iCtr++) {
        Customer customer1 = (Customer)customerArray.get_Item(iCtr);
        for (int y = 0; y < 15; y++) {
            customer1.get_CustomerOrders().Add(new Order("Order"
                + ((Int32)y).ToString()));
        }
    }
    // Display a wait cursor while the TreeNodes are being created.
    get_Cursor().set_Current(new Cursor("MyWait.cur"));
    // Suppress repainting the TreeView until all the objects have
    // been created.
    treeView1.BeginUpdate();
    // Clear the TreeView each time the method is called.
    treeView1.get_Nodes().Clear();
    // Add a root TreeNode for each Customer object in the ArrayList.
    for (int iCtr1 = 0; iCtr1 < customerArray.get_Count();
 iCtr1++) {
        Customer customer2 = (Customer)customerArray.get_Item(iCtr1);
        treeView1.get_Nodes().Add(new TreeNode(customer2.get_CustomerName()));
        // Add a child treenode for each Order object in the current
        // Customer object.
        for (int iCtr2 = 0; iCtr2 < customer2.get_CustomerOrders().
            get_Count(); iCtr2++) {
            Order order1 = (Order)customer2.get_CustomerOrders().
                get_Item(iCtr2);
            treeView1.get_Nodes().
                get_Item(customerArray.IndexOf(customer2)).get_Nodes().
                Add(new TreeNode(customer2.get_CustomerName()
 + "."
                + order1.get_OrderID()));
        }
    }
    // Reset the cursor to the default for all controls.
    get_Cursor().set_Current(Cursors.get_Default());
    // Begin repainting the TreeView.
    treeView1.EndUpdate();
} //FillMyTreeView
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Cursor コンストラクタ


Cursor プロパティ


Cursor メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

Cursor クラス
System.Messaging 名前空間
CreateCursor

Cursor メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.Runtime.Serialization.ISerializable.GetObjectData オブジェクトをシリアル化します。
参照参照

関連項目

Cursor クラス
System.Windows.Forms 名前空間
Cursors

Cursor メンバ

Cursor は、キューのメッセージを読み取るときに、MessageQueue 内の特定の場所を維持するために使用されます。

Cursor データ型で公開されるメンバを以下の表に示します。


パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

Cursor クラス
System.Messaging 名前空間
CreateCursor

Cursor メンバ

マウス ポインタの描画に使用されるイメージを表します。

Cursor データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド Cursor オーバーロードされます。  
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.Runtime.Serialization.ISerializable.GetObjectData オブジェクトをシリアル化します。
参照参照

関連項目

Cursor クラス
System.Windows.Forms 名前空間
Cursors

Cursor

名前 クルソル


英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「CURSOR」の関連用語

CURSORのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CURSORのページの著作権

   
実用日本語表現辞典実用日本語表現辞典
Copyright © 2026実用日本語表現辞典 All Rights Reserved.
デジタル大辞泉デジタル大辞泉
(C)Shogakukan Inc.
株式会社 小学館
IT用語辞典バイナリIT用語辞典バイナリ
Copyright © 2005-2026 Weblio 辞書 IT用語辞典バイナリさくいん。 この記事は、IT用語辞典バイナリの【カーソル】の記事を利用しております。
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.
日外アソシエーツ株式会社日外アソシエーツ株式会社
Copyright (C) 1994- Nichigai Associates, Inc., All rights reserved.

©2026 GRAS Group, Inc.RSS