Click here to Skip to main content
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:
^]
 
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 mhegazy94 460
1 Sergey Alexandrovich Kryukov 450
2 Kornfeld Eliyahu Peter 305
3 Ravi Bhavnani 200
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 6,890
1 OriginalGriff 6,761
2 CPallini 5,350
3 George Jonsson 3,609
4 Gihan Liyanage 2,797


Advertise | Privacy | Mobile
Web01 | 2.8.140922.1 | Last Updated 4 Sep 2012
Copyright © CodeProject, 1999-2014
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