指定したデータ ストリームで Cursor クラスの新しいインスタンスを初期化します。
Public Sub New( _
ByVal stream As Stream _)
[C#]
public Cursor(
Streamstream);
[C++]
public: Cursor(
Stream* stream);
[JScript]
public function Cursor(
stream : Stream);
パラメータ
- stream
Cursor の読み込み元のデータ ストリーム。
解説
stream で指定したデータ ストリームには、カーソル (.cur) ファイルを格納する必要があります。
メモ Cursor クラスでは、アニメーション カーソル (.ani ファイル) はサポートされません。
使用例
[Visual Basic, C#, C++] OpenFileDialog の OpenFile メソッドによって作成された Stream からカーソルを読み込む例を次に示します。このメソッドが呼び出されると、 OpenFileDialog がユーザーに表示されます。.cur ファイルを選択してこのダイアログを閉じると、このファイルが開かれ、返された Stream を使用して 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
[C#]
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());
}
}
[C++]
private:
void SetCursor() {
// Display an OpenFileDialog so the user can select a cursor.
OpenFileDialog* openFileDialog1 = new OpenFileDialog();
openFileDialog1->Filter = S"Cursor Files|*.cur";
openFileDialog1->Title = S"Select a Cursor File";
openFileDialog1->ShowDialog();
// If a .cur file was selected, open it.
if (!openFileDialog1->FileName->Equals(S"")) {
// Assign the cursor in the stream to the form's Cursor property.
this->Cursor = new System::Windows::Forms::Cursor(openFileDialog1->OpenFile());
}
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
Cursor クラス | Cursor メンバ | System.Windows.Forms 名前空間 | Cursor コンストラクタのオーバーロードの一覧 | Stream