Click here to Skip to main content
11,716,938 members (79,082 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC
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
Posted 4-Sep-12 6:27am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

And see the section dedicated to the CListCtrl here in CP:
http://www.codeproject.com/KB/list/[^]

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

Good luck!
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 449
1 OriginalGriff 265
2 F-ES Sitecore 210
3 Maciej Los 135
4 Jochen Arndt 120
0 Sergey Alexandrovich Kryukov 1,144
1 Maciej Los 509
2 OriginalGriff 505
3 Richard MacCutchan 440
4 CHill60 415


Advertise | Privacy | Mobile
Web01 | 2.8.150901.1 | Last Updated 4 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100