Click here to Skip to main content
14,880,436 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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));
  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

1 solution

Take a look at this article for basic usage:
Using the List Control[^]

And see the section dedicated to the CListCtrl here in CP:[^]

There are plenty of samples there, I'm sure one or another will help you.

Good luck!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900