Questo articolo è stato tradotto automaticamente. Per visualizzare l'articolo in inglese, selezionare la casella di controllo Inglese. È possibile anche visualizzare il testo inglese in una finestra popup posizionando il puntatore del mouse sopra il testo.
Traduzione
Inglese

Costruttore Cursor (Type, String)

 

Data di pubblicazione: ottobre 2016

Inizializza una nuova istanza della classe Cursor dalla risorsa specificata con il tipo di risorsa definito.

Spazio dei nomi:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public Cursor(
	Type type,
	string resource
)

Parametri

type
Type: System.Type

Oggetto Type della risorsa.

resource
Type: System.String

Nome della risorsa.

The following is an example of how to embed a cursor as a resource within your application. To embed the resource, reference the resource name followed by a comma, then its full assembly path. See the Example section to learn how to load the cursor from the embedded resource.

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
System_CAPS_noteNota

The resource reference when compiling as well as when referencing it in code, is case sensitive for both the C# and Visual Basic compilers.

The following code example displays a form that demonstrates using a custom cursor by using the Overload:System.Windows.Forms.Cursor.#ctor constructor. The custom T:System.Windows.Forms.Cursor is embedded in the application's resource file. The example requires that you have a cursor contained in a cursor file named MyCursor.cur. To compile this example using the command line, include the following flag: /res:MyCursor.Cur, CustomCursor.MyCursor.Cur

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 a bitmap
            //        1. Add a new cursor file to your project: 
            //                Project->Add New Item->General->Cursor File

            // --- 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 Resources"

            // 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");  

        }
    }
}

.NET Framework
Disponibile da 1.1
Torna all'inizio
Mostra: