Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I want display an icon in a listctrl, but it isn't working. What's wrong with it
C++
CImageList img;
SHFILEINFO lf;
::ZeroMemory(&lf,sizeof(lf));
HIMAGELIST ht;
ht=(HIMAGELIST) ::SHGetFileInfo(_T("C:\\"),NULL,&lf,sizeof(lf),SHGFI_LARGEICON|SHGFI_SYSICONINDEX);
img.Attach(ht);
DWORD style;
style=this->m_ListCtrl.GetExtendedStyle();
style=style|LVS_EX_CHECKBOXES;
this->m_ListCtrl.SetExtendedStyle(style);
this->m_ListCtrl.SetImageList(&img,LVSIL_NORMAL); 
LVITEM lm;
lm.mask=LVIF_IMAGE|LVIF_TEXT;
lm.iItem=0;
lm.iSubItem=0;
lm.iImage=lf.iIcon;
lm.pszText=(LPTSTR)_T("myCdevice");
m_ListCtrl.InsertItem(&lm);
Posted
Updated 30-Mar-10 4:42am
v2

1 solution

Try changing SHGFI_LARGEICON to SHGFI_SMALLICON and LVSIL_NORMAL to LVSIL_SMALL and see if it works.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900