This documentation is archived and is not being maintained.
Bitmap.GetHicon Method
.NET Framework 1.1
Returns the handle to an icon.
[Visual Basic] Public Function GetHicon() As IntPtr [C#] public IntPtr GetHicon(); [C++] public: IntPtr GetHicon(); [JScript] public function GetHicon() : IntPtr;
Return Value
A Windows handle to an icon.
Example
[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:
- Creates a Bitmap object.
- Draws that object to the screen.
- Gets an icon handle for the Bitmap object.
- Does something with the handle.
[Visual Basic] 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] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
Show: