Click to See Complete Forum and Search --> : Adding icon to subitems of CListCtrl


April 19th, 1999, 05:28 AM
Hi everyone !
How can I add an icon to the subitem in CListCtrl? I think it is possible using owner-drawn list control? But I don't know how.
Can someone help me?

Thanks in advance

Hussam
April 19th, 1999, 06:23 AM
You have first to create an image list and then add it to the a CListView

m_pImageList=new CImageList;
m_pImageList->Create(16,16, TRUE, 2, 0);
m_pImageList->Add(theApp.LoadIcon (IDI_LOCKICON));

m_pImageList->Add(theApp.LoadIcon(IDI_UNLOCKICON));

m_listFiles.SetImageList(m_pImageList, LVSIL_SMALL);


when you after all you want to add items you have to set the style of the item like this
item.mask = LVIF_TEXT | LVIF_IMAGE;
and the index of the image
item.iImage = 1;

I hope this helps you.
Hussam

Vicky
April 20th, 1999, 07:11 AM
Thanks for the reply Hussam. But this will only add icons to the items (which I am able to add) and not to the subitems. If you have a way to add icons to the
subitems, let me know.

Vicky

Rob Woodruff
April 21st, 1999, 07:30 AM
The LV_COLUMN structure has two new fields (Version 4.7 of common controls) that allow you to specify the placement of bitmaps (from an image list) in the various columns (iImage and iOrder). Check them out. Earlier versions require complete owner-draw....