Declare Function DrawIcon Lib "user32.dll" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
DrawIcon displays an icon on a device. The icon's position is determined by a coordinate pair passed to the function identifying the coordinates of the upper-left corner of the icon. The icon is always drawn in its normal dimensions.
If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns a non-zero value.
None.
' This code is licensed according to the terms and conditions listed here. ' Display the first icon (index 0) stored in the executable file ' C:\MyApp\Prog.exe on window Form1.  The icon must be destroyed after the ' program finishes using it. Dim hIcon As Long  ' handle to the function gotten from the executable file Dim retval As Long  ' return value ' Extract the first icon stored in the aforementioned executable file. hIcon = ExtractIcon(App.hInstance, "C:\MyApp\Prog.exe", 0) ' Only attempt to display the icon if we successfully extracted it. If hIcon = 0 Then   Debug.Print "Failed to extract the icon -- aborting."   End  ' terminate the program Else   ' Display the icon at coordinates (100, 75) on window Form1.   retval = DrawIcon(Form1.hDC, 100, 75, hIcon)   ' Although the icon's image is still visible, the icon itself is not in use.   ' Therefore we destroy it to free up resources.   retval = DestroyIcon(hIcon) End If DrawIconEx
Icons
Go back to the alphabetical Function listing.
 Go back to the Reference section index.
 Last Modified: August 4, 1999
 This page is copyright © 1999 Paul Kuliniewicz.   Copyright Information  Revised October 29, 2000
 Go back to the Windows API Guide home page.
 E-mail: vbapi@vbapi.com  Send Encrypted E-Mail
 This page is at http://www.vbapi.com/ref/d/drawicon.html