How can i add an image to combo box from resource file? please provide an example code.
Thanks alot.
How to add image to combo box from .res?
Re: How to add image to combo box from .res?
You need to load the image into an image list and then assign this image list to the control. The Events sample demonstrates how to assign an image list to the control.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: How to add image to combo box from .res?
The Events sample demonstrates how to load images from a directory to the image list.TiKu wrote:You need to load the image into an image list and then assign this image list to the control. The Events sample demonstrates how to assign an image list to the control.
Code: Select all
hImgLst = ImageList_Create(16, 16, IIf(bComctl32Version600OrNewer, ILC_COLOR32, ILC_COLOR24) Or ILC_MASK, 14, 0)
If Right$(App.Path, 3) = "bin" Then
iconsDir = App.Path & "\..\res\"
Else
iconsDir = App.Path & "\res\"
End If
iconsDir = iconsDir & "16x16" & IIf(bComctl32Version600OrNewer, "x32bpp\", "x8bpp\")
iconPath = Dir$(iconsDir & "*.ico")
While iconPath <> ""
hIcon = LoadImage(0, StrPtr(iconsDir & iconPath), IMAGE_ICON, 16, 16, LR_LOADFROMFILE Or LR_DEFAULTSIZE)
If hIcon Then
ImageList_AddIcon hImgLst, hIcon
DestroyIcon hIcon
End If
iconPath = Dir$
Wend
Can you please provide me the code to do so.
Re: How to add image to combo box from .res?
I wrote that it demonstrates how to assign an image list to the control.
Loading images from resources into an image list is a common task and you'll find code for it on www.planetsourcecode.com. Actually it doesn't matter that you want to load the images into an image list. Have a look at the documentation of the LoadImage function. It can be used to load images from resources instead of files. If the resources contain one bitmap with all the icons in it, you can also use ImageList_LoadImage.
Loading images from resources into an image list is a common task and you'll find code for it on www.planetsourcecode.com. Actually it doesn't matter that you want to load the images into an image list. Have a look at the documentation of the LoadImage function. It can be used to load images from resources instead of files. If the resources contain one bitmap with all the icons in it, you can also use ImageList_LoadImage.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!