DarkMercenary44
Technical User
Ok, what I'm trying to do is extract an icon from a file [I've got this part finished] I'm using a custom control from vbsmart.com that is a ownerdrawn menu, which allows pictures. I'm trying to let the user add thier own menu items (programs, files, etc.) When they do so it will get the icon from that file and put it in the menu.
The author of the code states that the picture property of the menu will accept "LoadPicture", and any ".Picture" properties of ImageList, PictureBox, and Image.
This code loads the picture into a picture box, and then I try to add the picture to the menu by doing this...
Menu.Add 0,"Test", , "Test Menu Caption", pb_Buffer.Picture
And for some reason it's not being recognized as a picture, but I can assign it to other picture boxes from the pb_Buffer.Picture property.
Can someone tell me if I set this up wrong or if you think it's just the control. If you think it's the control do you know of any other real good owner drawn menu controls out there...
here's the code I'm using for extraction...
DarkMercenary
darkmercenary@earthlink.net
-=Man who stand on toilet is high on pot=-
The author of the code states that the picture property of the menu will accept "LoadPicture", and any ".Picture" properties of ImageList, PictureBox, and Image.
This code loads the picture into a picture box, and then I try to add the picture to the menu by doing this...
Menu.Add 0,"Test", , "Test Menu Caption", pb_Buffer.Picture
And for some reason it's not being recognized as a picture, but I can assign it to other picture boxes from the pb_Buffer.Picture property.
Can someone tell me if I set this up wrong or if you think it's just the control. If you think it's the control do you know of any other real good owner drawn menu controls out there...
here's the code I'm using for extraction...
Code:
Public Sub GetExtractIcon(FileName As String, pb_Buffer As PictureBox)
Dim SmallIcon As Long
Dim nSmallIcon As Long
Dim nLargeIcon As Long
Dim pic As PicBmp
Dim Ipic As IPictureDisp
Dim IID_IDispatch As GUID
If ExtractIconEx(FileName, 0, nLargeIcon, nSmallIcon, 1) > 0 Then
SmallIcon = nSmallIcon
End If
If SmallIcon <> 0 Then
With IID_IDispatch
.Data1 = &H20400
.Data4(0) = &HC0
.Data4(7) = &H46
End With
' Fill Pic with necessary parts.
With pic
.Size = Len(pic) ' Length of structure.
.tType = vbPicTypeIcon ' Type of Picture (bitmap).
.hBmp = SmallIcon ' Handle to bitmap.
.hPal = 0&
End With
' Create Picture object.
Call OleCreatePictureIndirect(pic, IID_IDispatch, 1, Ipic)
' Return the new Picture object.
Set frm_Main.pb_Buffer.Picture = Ipic
DestroyIcon SmallIcon
End If
End Sub
darkmercenary@earthlink.net
-=Man who stand on toilet is high on pot=-