I need to create my thumbnails into the list. For this I have used two classes CListCtrl
and CImageList
. For test I created the bitmaps:
My code
m_imageList.Create(IDB_BITMAP1, 16, 1, RGB(255, 0, 255));
int nSize = m_imageList.GetImageCount();
for (int i = 0; i < nSize; i++)
{
CString str = L"";
str.Format(L"%d", i);
m_listCtrl.InsertItem(LVIF_TEXT, i, str, 0, 0, 0, NULL);
LVITEM lvi = { 0 };
lvi.mask = LVCF_IMAGE;
lvi.iItem = i;
lvi.iImage = i;
BOOL bRes = m_listCtrl.SetItem(&lvi);
}
m_listCtrl.SetImageList(&m_imageList, TVSIL_NORMAL);
But after running it I get a list with the first icon:
I would like to see all icons. Is it possible? I found several solutions (for example, How to Add Icon in cells of a column CListCtrl) on this site, but they show the same result - one icon.
My project (MSVS2022) is here
Use: m_listCtrl.InsertItem(LVIF_TEXT | LVIF_IMAGE, i, str, 0, 0, i, NULL);
m_imageList.Create(IDB_BITMAP1, 16, 1, RGB(255, 0, 255));
m_listCtrl.SetImageList(&m_imageList, TVSIL_NORMAL);
int nSize = m_imageList.GetImageCount();
for (int i = 0; i < nSize; i++)
{
CString str = L"";
str.Format(L"%d", i);
m_listCtrl.InsertItem(LVIF_TEXT | LVIF_IMAGE, i, str, 0, 0, i, NULL);
}