
VB4.0 ExtractIcon, DrawIcon API calls
OK...let me know what I'm doing wrong! I just can't figure this one
out!
I'm extracting icons from exe's and dll's to place them in a ImageList
to get them on a VB 4.0 (32bit) toolbar custom control.
Here's what I'm doing.....
Declarations:
Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As
Long, ByVal y As Long, ByVal hIcon As Long) As Long
Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA"
(ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal
nIconIndex As Long) As Long
Declare Function GetModuleHandle Lib "kernel32" Alias
"GetModuleHandleA" (ByVal lpModuleName As String) As Long
Code:
hModule = GetModuleHandle("d:\vbpro\VB32.EXE")
Iconh = ExtractIcon(hModule, IconFile + Chr$(0), IconNumber - 1)
z% = DrawIcon(Form1.TempPicture.hdc, x, y, Iconh)
Dim imgX As ListImage
Dim btnX As Button
Set imgX = Form1.ImageList1.ListImages.Add(, "JUNK",
Form1.TempPicture.Picture))
Set btnX = Form1.Toolbar1.Buttons.Add(, "JUNK", , 0, "JUNK")
When it get to the point where I'm attempting to add a picture to the
ListImage control, I get a Run Time Error 431 "Invalid
Picture"...!!!???? Funny thing is...I can't do much of anything with
this extracted picture (Icon). I get basically the same type of error
if I try and use the SavePicture method on my picture box control.
All this worked great under VB 3.0....except the toolbar control just
wasn't there. As stated in the declarations above, I made sure I'm
calling all the 32 library functions instead of the 16 bit. The icon
makes it fin into the TempPicture control...but no dice when I try and
copy it to another control with the Picture property.
WHAT GIVES.....!!!!??????
Thanks in advance!!
Bob Templeton.