次の方法で共有


Bitmap.GetHicon メソッド

アイコンを識別するハンドルを返します。

Public Function GetHicon() As IntPtr
[C#]
public IntPtr GetHicon();
[C++]
public: IntPtr GetHicon();
[JScript]
public function GetHicon() : IntPtr;

戻り値

アイコンを識別する Windows ハンドル。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • Bitmap オブジェクトを作成します。
  • 画面にそのオブジェクトを描画します。
  • Bitmap オブジェクトのアイコン ハンドルを取得します。
  • ハンドルを使用してなんらかの作業を行います。
 
Public Sub GetHicon_Example(e As PaintEventArgs)
' Create a Bitmap object from an image file.
Dim myBitmap As New Bitmap("Grapes.jpg")
' Draw myBitmap to the screen.
e.Graphics.DrawImage(myBitmap, 0, 0)
' Get an Hicon for myBitmap.
Dim HIcon As IntPtr = myBitmap.GetHicon()
End Sub
        
[C#] 
public void GetHicon_Example(PaintEventArgs e)
{
// Create a Bitmap object from an image file.
Bitmap myBitmap = new Bitmap("Grapes.jpg");
// Draw myBitmap to the screen.
e.Graphics.DrawImage(myBitmap, 0, 0);
// Get an Hicon for myBitmap.
IntPtr Hicon = myBitmap.GetHicon();
// Do something with Hicon.
// ...
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

Bitmap クラス | Bitmap メンバ | System.Drawing 名前空間