How to add image to combo box from .res?
Posted: 09 Sep 2012, 16:14
How can i add an image to combo box from resource file? please provide an example code.
Thanks alot.
Thanks alot.
Unicode ActiveX controls for Visual Basic 6
https://timosoft-software.de/forum/
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