Cursor クラスとは? わかりやすく解説

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 プロパティ割り当てますまた、CursorCurrent プロパティ割り当てアプリケーション レベルカーソル表示することもできます。たとえば、アプリケーションテキストファイル編集する場合は、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 は再描画されません。TreeViewTreeNode オブジェクト作成して描画する間、待機 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) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からCursor クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からCursor クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からCursor クラス を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Cursor クラス」の関連用語

Cursor クラスのお隣キーワード
検索ランキング

   

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



Cursor クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS