by Dennis John (3 Submissions)
Category: Windows API Call/Explanation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 2nd January 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Draw Any Icon on form
API Declarations
Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hicon As Long) As Long
Private Declare Function DestroyIcon Lib "user32" (ByVal hicon As Long) As Long
Dim hicon As Long ' Handle to icon
Dim rval As Long ' Return value
Dim index As Long 'Icon index
Private Sub Command1_Click()
index = 0
'Extract Icon from explorer.exe of index=0
'Give the path of any icon
hicon = ExtractIcon(App.hInstance, "c:\windows\WINUPD.ICO", index)
rval = DrawIcon(Form1.hdc, 150, 150, hicon) 'draw icon on form
rval = DestroyIcon(hicon) 'Destroy the icon handle
'Extract and Draw Icon for index=0
End Sub