初始化列表
SHFILEINFO rInfo;
HIMAGELIST hImglist;
hImglist = (HIMAGELIST) SHGetFileInfo ( L"", 0, &rInfo, sizeof(SHFILEINFO),
SHGFI_ICON | SHGFI_SMALLICON |
SHGFI_SYSICONINDEX );
m_cFileImages.Attach(hImglist);
m_ctrlFileList.SetImageList(&m_cFileImages, LVSIL_SMALL);
m_ctrlFileList.InsertColumn(XLIST_NAME_ITEM,L"NAME", LVCFMT_LEFT, 360);
m_ctrlFileList.InsertColumn(XLIST_TYPE_ITEM,L"TYPE", LVCFMT_LEFT, 160);
m_ctrlFileList.SetExtendedStyle ( m_ctrlFileList.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
获取文件信息:
LVITEMW stItem;
SHFILEINFOW stInfo;
// 获取图标信息,与文件类型信息
SHGetFileInfoW(
lpwzFile_,
0,
&stInfo,
sizeof(SHFILEINFOW),
SHGFI_SYSICONINDEX | SHGFI_TYPENAME|SHGFI_ATTRIBUTES);
DestroyIcon(stProp_.stInfo.hIcon);
//填充 rItem
stItem.mask = LVIF_IMAGE | LVIF_TEXT;
stItem.iImage = stInfo.iIcon;
//图标改成若隐若现状态
if ( stInfo.dwAttributes & SFGAO_GHOSTED )
{
stItem.mask |= LVIF_STATE;
stItem.state = stItem.stateMask = LVIS_CUT;
}
显示列表信息
stItem.pszText = stInfo.szDisplayName;
stItem.iItem = nIndex;
m_ctrlFileList.InsertItem (&(it->stItem));
m_ctrlFileList.SetItemText(nIndex, XLIST_TYPE_ITEM, stInfo.szTypeName);
在列表控件中显示文件图标与类型
最新推荐文章于 2020-03-20 13:04:17 发布