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
Printable View
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
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
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
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....