Cursor Constructor (Stream^)

 

Initializes a new instance of the Cursor class from the specified data stream.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
Cursor(
	Stream^ stream
)

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.

System_CAPS_noteNote

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:
   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
Available since 1.1
Return to top
Show: