Initializes a new instance of the Cursor class from the specified data stream.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Public Sub New ( _ stream As Stream _ )
public Cursor(
Stream stream
)
public:
Cursor(
Stream^ stream
)
new :
stream:Stream -> Cursor
Parameters
- stream
- Type: System.IO.Stream
The data stream to load the Cursor from.
The data stream specified by stream must contain a cursor (.cur) file.
Note
|
|---|
|
Animated cursors (.ani files) are not supported by the Cursor class. |
The following code example loads a cursor from a Stream created by the OpenFile method of an OpenFileDialog. When the method is called, an OpenFileDialog is displayed to the user and when a. CUR file is selected and the dialog closed, the file is opened and the Stream returned is used to create a 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() ); } }
.NET Framework
Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0.NET Framework Client Profile
Supported in: 4, 3.5 SP1Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note