Bitmap.GetHicon メソッドとは? わかりやすく解説

Bitmap.GetHicon メソッド

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

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Function GetHicon As
 IntPtr
Dim instance As Bitmap
Dim returnValue As IntPtr

returnValue = instance.GetHicon
public IntPtr GetHicon ()
public:
IntPtr GetHicon ()
public IntPtr GetHicon ()
public function GetHicon () : IntPtr

戻り値
Bitmap と同じイメージを持つアイコン対すWindows ハンドル

例外例外
解説解説

最初は、ハンドルから作成されアイコンサイズは元のビットマップと同じです。

使用例使用例

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

<System.Runtime.InteropServices.DllImportAttribute("user32.dll")>
 _
    Private Shared Function
 DestroyIcon(ByVal handle _ 
    As IntPtr) As Boolean
 
    End Function

   Private Sub GetHicon_Example(ByVal
 e As PaintEventArgs)

        ' Create a Bitmap object from an image file.
        Dim myBitmap As New
 Bitmap("c:\FakePhoto.jpg")

        ' Draw myBitmap to the screen.
        e.Graphics.DrawImage(myBitmap, 0, 0)

        ' Get an Hicon for myBitmap.
        Dim HIcon As IntPtr = myBitmap.GetHicon()
    
    ' Create a new icon from the handle.
    Dim newIcon as Icon = System.Drawing.Icon.FromHandle(HIcon)

        ' Set the form Icon attribute to the new icon.
        Me.Icon = newIcon

    ' Destroy the icon, since the form creates its 
    ' own copy of the icon.
    DestroyIcon(newIcon.Handle)
    
    End Sub
 [System.Runtime.InteropServices.DllImport("user32.dll", CharSet=CharSet.Auto)]
    extern static bool DestroyIcon(IntPtr handle);
   
private void GetHicon_Example(PaintEventArgs
 e)
    {
                 
        // Create a Bitmap object from an image file.
        Bitmap myBitmap = new Bitmap(@"c:\FakePhoto.jpg");
                 
        // Draw myBitmap to the screen.
        e.Graphics.DrawImage(myBitmap, 0, 0);
                 
        // Get an Hicon for myBitmap.
        IntPtr Hicon = myBitmap.GetHicon();
    
    // Create a new icon from the handle. 
    Icon newIcon = Icon.FromHandle(Hicon);
              
        // Set the form Icon attribute to the new icon.
        this.Icon = newIcon;
        
        // Destroy the Icon, since the form creates
    // its own copy of the icon.
        DestroyIcon(newIcon.Handle);
    
    }
private:
   [System::Runtime::InteropServices::DllImportAttribute("user32.dll",CharSet=CharSet::Auto)]
   static bool DestroyIcon( IntPtr handle );

public:
   [SecurityPermission(SecurityAction::Demand, Flags=SecurityPermissionFlag::UnmanagedCode)]
   void GetHicon_Example( PaintEventArgs^ e )
   {
      
      // Create a Bitmap object from an image file.
      Bitmap^ myBitmap = gcnew Bitmap( "c:\\FakePhoto.jpg" );
      
      // Draw myBitmap to the screen.
      e->Graphics->DrawImage( myBitmap, 0, 0 );
      
      // Get an Hicon for myBitmap.
      IntPtr Hicon = myBitmap->GetHicon();
      
      // Create a new icon from the handle. 
      System::Drawing::Icon^ newIcon = ::Icon::FromHandle( Hicon );
      
      // Set the form Icon attribute to the new icon.
      this->Icon = newIcon;
      
      // Destroy the Icon, since the form creates
      // its own copy of the icon.
      DestroyIcon( newIcon->Handle );
   }
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からBitmap.GetHicon メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からBitmap.GetHicon メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からBitmap.GetHicon メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

Bitmap.GetHicon メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Bitmap.GetHicon メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS