I think I have a solution to my problem: in the absence of a working 64-bit imagelist control, the option is given to manual create a CImageList object and load the icons from the hard drive. This isn't a good option because, in addition to your Excel sheet, you also have to supply a whole bunch of icon filesto the enduser.
The option of temporarily placing an icon from Excel on the hard drive and then adding it to the CImageList object isn't very appealing either.
I've come up with the following solution: you usually needs the icons on your userforms, so place then on the userform:
1) Place image controls containing the icon needed on your userform. You can hide the image controls from the user with visible=false.
2) Extend the CImageList class with the following procedure:
Public Sub AddPicture(ByVal myImageControl As msforms.Image)
Dim ptrBmp As LongPtr
Dim lngRes As Long
If m_ptrImageList = 0 Then Exit Sub
ptrBmp = myImageControl.Picture
lngRes = ImageList_Add(m_ptrImageList, ptrBmp, 0)
DeleteObject ptrBmp
End Sub
3) In your code, you can now create a CImageList object and populate it with icons from the hard disk or from your image objects as follows:
Dim m_objImageList As CImageList
Private Sub UserForm_Initialize()
Set m_objImageList = New CImageList
With m_objImageList
.Create 16, 16, ThisWorkbook.Path & "\Images\"
.AddImage "Project.bmp" ' Load from hard disk
.AddImage "userform.bmp" ' Load from hard disk
.AddPicture Image1 ' Load from Image control
End With
With iGrid1
.BeginUpdate
.SetImageList m_objImageList.hImageList
.ColCount = 1
.RowCount = 3
.CellValue(1, 1) = "Project"
.CellIcon(1, 1) = 1
.CellValue(2, 1) = "UserForm"
.CellIcon(2, 1) = 2
.CellValue(3, 1) = "Map"
.CellIcon(3, 1) = 3
.AutoWidthCols
.AutoHeightRows
.EndUpdate
End With
End Sub