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:
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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 695
1 OriginalGriff 518
2 Abhinav S 313
3 thatraja 245
4 CPallini 130
0 Sergey Alexandrovich Kryukov 8,372
1 OriginalGriff 4,830
2 Peter Leow 3,784
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 4 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid