Puffeltje
2025-05-29T15:48:14Z
At the moment I am trying to fill IGRID7 ActiveX 64bit in VBA with icons. In your example you use the following code:

Set m_objImageList = New CImageList
With m_objImageList
.Create 24, 24, ThisWorkbook.Path & "\Images\"
.AddImage "RedSquare.bmp"
.AddImage "OrangeSquare.bmp"
.AddImage "GreenSquare.bmp"
End With

I do not want to use extra files but store the files in the excel document itself. Is it possible to fill a CImagelist with the content of various image objects?
Igor/10Tec
2025-05-30T15:03:56Z
The CImageList.AddImage method internally uses the LoadImage WinAPI function that works with graphical files stored on hard drives. It's not possible to feed other kinds of bitmap sources into the AddImage method because of this. I do not know whether it is possible to write another version of the AddImage method that can load images directly from Excel sheets.

Perhaps, the fastest and simplest way to implement your task would be reusing of the existing AddImage method. If Excel allows saving its images from sheets to hard drive, you can temporarily save your images on a hard drive in a temp folder during grid initialization and upload them into CImageList by using the existing AddImage method.
Puffeltje
2025-07-10T14:42:42Z
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
Igor/10Tec
2025-07-11T14:31:58Z
If I understand it right, you can store a series of images in one Image control?
Puffeltje
2025-07-11T14:47:55Z

No, I place a separate image control on my userform for each icon. I can add each image control to the CImageList object. I also have a visual overview on the userform showing which icons are available in the CImageList.
Igor/10Tec
2025-07-14T10:05:40Z
According to the documentation  for the WinAPI ImageList_Add function, it can be used to add a strip of images. Here is the description of its second parameter, hbmImage:

A handle to the bitmap that contains the image or images. The number of images is inferred from the width of the bitmap.

You can try that approach too to minimize the number of Image controls on your forms.
Puffeltje
2025-07-15T07:45:33Z
Thanks, it's working.
That saves a lot of image controls on my userform.

Igor/10Tec
2025-11-19T15:28:43Z
Great news — we released true 64-bit 10Tec ImageList ActiveX yesterday.