listctrl和shgetfileinfo [英] listctrl and shgetfileinfo

查看:129
本文介绍了listctrl和shgetfileinfo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在listctrl中显示一个图标,但是它不起作用.怎么了

I want display an icon in a listctrl, but it isn''t working. What''s wrong with it

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);

推荐答案

尝试将SHGFI_LARGEICON更改为SHGFI_SMALLICON,将LVSIL_NORMAL更改为LVSIL_SMALL,看看是否可行.
Try changing SHGFI_LARGEICON to SHGFI_SMALLICON and LVSIL_NORMAL to LVSIL_SMALL and see if it works.


这篇关于listctrl和shgetfileinfo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆