ListView加入系统图标时,出现运行后,桌面等图标消失了(高分)

solarsoft 2003-10-06 02:47:48
HIMAGELIST hSystemSmallImageList, hSystemLargeImageList;
SHFILEINFO ssfi, lsfi;

//get a handle to the system small icon list
hSystemSmallImageList =
(HIMAGELIST)SHGetFileInfo(
(LPCTSTR)_T("C:\\"),
0,
&ssfi,
sizeof(SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
//attach it to the small image list
//--DON'T FORGET TO PUT m_smallImageList.Detach(); in your destructor

m_SmallImgList.Attach(hSystemSmallImageList);

//do the same for the large
hSystemLargeImageList =
(HIMAGELIST)SHGetFileInfo(
(LPCTSTR)_T("C:\\"),
0,
&lsfi,
sizeof(SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_ICON);
m_LargeImgList.Attach(hSystemLargeImageList);

//Set the list control image list
GetListCtrl().SetImageList(&m_SmallImgList, LVSIL_SMALL);
GetListCtrl().SetImageList(&m_LargeImgList, LVSIL_NORMAL);

加到OnInitialUpdate(),程序一运行,图标还在,结束后,系统图标都消失了,不知道是什么原因,望予以解决.
...全文
57 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
solarsoft 2003-10-07
  • 打赏
  • 举报
回复
又是自己解决了,咳,CSDN,在现在的程序中我在OnDestroy()加入 m_SmallImgList.Detach();
m_LargeImgList.Detach();可实际运行过程中,这个OnDestroy并没有执行,索性把它放入构析函数中,这个类的结束就必定会执行,上述的问题就这样解决了.
solarsoft 2003-10-06
  • 打赏
  • 举报
回复
m_SmallImgList,m_LargeImgList定义为CImageList,可能是程序结束运行时销毁了m_SmallImgList,m_LargeImgList,所以一定运行结束就图标消失了,不知道如何避免
wuxfBrave 2003-10-06
  • 打赏
  • 举报
回复
用copy
wuxfBrave 2003-10-06
  • 打赏
  • 举报
回复
不要用Attach试试
howtotell 2003-10-06
  • 打赏
  • 举报
回复
试试用CImageList
howtotell 2003-10-06
  • 打赏
  • 举报
回复
explorer.exe出错?
solarsoft 2003-10-06
  • 打赏
  • 举报
回复
我先顶

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧