I have a virtual CListCtrl, m_Infobox, that handles LVN_GETDISPINFO. It has 1 column and no coulumn headers.
It has an image list:
m_VirtualImageList.Create(16, 16, ILC_COLOR32 | ILC_MASK, 1,1);
m_Infobox.SetImageList(&(m_imagelistUtil.m_VirtualImageList), LVSIL_SMALL);
In OnGetdispinfo i handle when the list wants text
if (pItem->mask & LVIF_TEXT) {
lstrcpyn(pItem->pszText, m_csColumn1, pItem->cchTextMax);
}
and that works just fine. But when I add handling for icons thing start to go wrong.
if( pItem->mask & LVIF_IMAGE) {
HICON hIcon = reinterpret_cast<HICON>(::LoadImage ( AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_COPY),IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
m_imagelistUtil.m_VirtualImageList.Replace(0,hIcon);
pItem->iImage = 0;
}
When I start a job and add rows as I process files, the first few hundred lines works fine, then the list either goes blank or start drawing its lines all over the dialog, and not just in the listctrl.
This only happens when I try to insert icons on each row.
In the example above I try to use the same icon for all rows, but it doesn't matter where I get the icons (resource, other image list, system image list), the behaviour is the same.
Is there something I don't understand in regards to working with icons?
I have searched the web and tried everything I can think of, and I'm out of ideas.
All suggestions appreciated.
Best regards,
Urban Dahlberg