Bitmap.GetHicon メソッド
アセンブリ: System.Drawing (system.drawing.dll 内)

Dim instance As Bitmap Dim returnValue As IntPtr returnValue = instance.GetHicon
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 ); }

- SecurityPermission (アンマネージ コードを呼び出すために必要なアクセス許可)。UnmanagedCode (関連する列挙体)

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からBitmap.GetHicon メソッドを検索する場合は、下記のリンクをクリックしてください。

- Bitmap.GetHicon メソッドのページへのリンク