Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Initialisiert eine neue Instanz der Cursor-Klasse aus der angegebenen Ressource mit dem angegebenen Ressourcentyp.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Sub New ( _
type As Type, _
resource As String _
)
'Usage
Dim type As Type
Dim resource As String
Dim instance As New Cursor(type, resource)
public Cursor (
Type type,
string resource
)
public:
Cursor (
Type^ type,
String^ resource
)
public Cursor (
Type type,
String resource
)
public function Cursor (
type : Type,
resource : String
)
Parameter
- type
Der Ressourcen-Type.
- resource
Der Name der Ressource.
Hinweise
Das folgende Beispiel veranschaulicht das Einbetten eines Cursors als Ressource in der Anwendung. Verweisen Sie zum Einbetten der Ressource auf den Ressourcennamen, dem ein Komma und der vollständige Assemblypfad folgen. Im Beispielabschnitt erfahren Sie, wie der Cursor aus der eingebetteten Ressource geladen werden kann.
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
Hinweis
Im Ressourcenverweis wird für C#- und Visual Basic-Compiler sowohl bei der Kompilierung als auch bei Verweisen im Code die Groß- und Kleinschreibung beachtet.
Beispiel
Im folgenden Codebeispiel wird anhand eines Formulars die Verwendung eines benutzerdefinierten Cursors mit dem Cursor-Konstruktor veranschaulicht. Der benutzerdefinierte Cursor wird in die Ressourcendatei der Anwendung eingebettet. Für das Beispiel muss ein in der Cursordatei MyCursor.cur enthaltener Cursor vorhanden sein. Geben Sie zum Kompilieren des folgenden Beispiels an der Befehlszeile das folgende Flag an: /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
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
Cursor-Klasse
Cursor-Member
System.Windows.Forms-Namespace
Weitere Ressourcen
Gewusst wie: Erstellen von der Befehlszeile aus
Erstellen von der Befehlszeile aus (Visual Basic)