帮忙看下,CTreeCtrl控件通过SetImageList设置与图像列表关联后如何取消它们的关联关系

jason08010 2014-12-16 05:16:12
如题,
想执行切换树形控件图标操作,但现在一旦设置了关联后,就不知道怎样取消原先的关联关系?
再想重新设置另外一套图像列表与树形控件行不通?
...全文
398 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
jason08010 2014-12-18
  • 打赏
  • 举报
回复
调试状态下,可重新设置关联,并能显示图标,但直接运行图标却不显示。。。 无语啦!
schlafenhamster 2014-12-17
  • 打赏
  • 举报
回复
1. 不需要 先设置为 0; 2. 如果 不自烩, 不需要 Invalidate 3. 第二个 HIMAGELIST 必须 创建 对。
jacksonfan 2014-12-17
  • 打赏
  • 举报
回复
引用 6 楼 jason08010 的回复:
试过SetImageList(NULL, LVSIL_SMALL);,然后再设置新图像列表还是不行
Type of image list to set. The image list can be one of the following values: 第二个参数,没有你写的那个
jason08010 2014-12-17
  • 打赏
  • 举报
回复
引用 3 楼 allenhiman 的回复:
CTreeCtrl tt; tt.SetItem(); tt.SetItemImage(); 这是更改图标的方法 全部更新imagelist 可以销毁原来的imagelist设置新的 也可以更改原来的imagelist imagelist.add imagelist.replace 等等
SetItemImage();只是更改 未选中 或 选中时选择图像列表对应序号的图标吧? 我是想要重新设置另外的图像列表
jason08010 2014-12-17
  • 打赏
  • 举报
回复
引用 4 楼 jacksonfan 的回复:
CTreeCtrl::SetImageList CImageList* SetImageList( CImageList * pImageList, int nImageListType ); Return Value Pointer to the previous image list, if any; otherwise NULL. Parameters pImageList Pointer to the image list to assign. If pImageList is NULL, all images are removed from the tree view control. nImageListType Type of image list to set. The image list can be one of the following values: TVSIL_NORMAL Sets the normal image list, which contains the selected and nonselected images for the tree view item. TVSIL_STATE Sets the state image list, which contains the images for tree view items that are in a user-defined state. Remarks Call this function to set the normal or state image list for a tree view control and redraw the control using the new images. 这个函数不是可以实现么
试过SetImageList(NULL, LVSIL_SMALL);,然后再设置新图像列表还是不行
jason08010 2014-12-17
  • 打赏
  • 举报
回复
引用 1 楼 vocanicy 的回复:
重设SetImageList之后,再更新每个节点的图标
有具体点的代码吗?怎样更新每个节点的图标? 因为是重写DrawItem函数,在它里面绘制图标等重绘操作; LV_ITEM lvi; int nItem = lpDrawItemStruct->itemID; lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_INDENT | LVIF_PARAM; lvi.iItem = nItem; lvi.iSubItem =0; lvi.pszText = szBuff; lvi.cchTextMax = sizeof(szBuff); lvi.stateMask = 0xFFFF; GetItem(&lvi); 然后对应的图像就是lvi.iImage; 哪怕是先设置SetImageList(NULL, LVSIL_SMALL); 再设置另外一套图像列表也没设置进去,还是显示之前的图像!
jacksonfan 2014-12-17
  • 打赏
  • 举报
回复
CTreeCtrl::SetImageList CImageList* SetImageList( CImageList * pImageList, int nImageListType ); Return Value Pointer to the previous image list, if any; otherwise NULL. Parameters pImageList Pointer to the image list to assign. If pImageList is NULL, all images are removed from the tree view control. nImageListType Type of image list to set. The image list can be one of the following values: TVSIL_NORMAL Sets the normal image list, which contains the selected and nonselected images for the tree view item. TVSIL_STATE Sets the state image list, which contains the images for tree view items that are in a user-defined state. Remarks Call this function to set the normal or state image list for a tree view control and redraw the control using the new images. 这个函数不是可以实现么
allenhiman 2014-12-17
  • 打赏
  • 举报
回复
CTreeCtrl tt; tt.SetItem(); tt.SetItemImage(); 这是更改图标的方法 全部更新imagelist 可以销毁原来的imagelist设置新的 也可以更改原来的imagelist imagelist.add imagelist.replace 等等
schlafenhamster 2014-12-17
  • 打赏
  • 举报
回复
CTreeCtrl::SetImageList 返回值 Pointertothepreviousimagelist,ifany;otherwise. 返回指向先前的图像列表的指针(如果有);否则返回NULL 参数说明 Pointertotheimagelisttoassign.Ifis,allimagesareremovedfromthetreeviewcontrol. 指向要被分配的图像列表的指针。如果pImageList是NULL,则从treeview控件中删除所有的图像。 Typeofimagelisttoset.Theimagelistcanbeoneofthefollowingvalues: 要设置的图像列表的类型。图像列表可以是下列值之一:lTVSIL_NORMAL获取常规的图像列表,它包含了该treeview项的被选择的和不被选择的图像。lTVSIL_STATE获取状态图像列表,它包含了处于用户定义状态的treeview项的图像。 Setsthenormalimagelist,whichcontainstheselectedandnonselectedimagesforthetreeviewitem.Setsthestateimagelist,whichcontainstheimagesfortreeviewitemsthatareinauser-definedstate.
jacksonfan 2014-12-17
  • 打赏
  • 举报
回复
引用 11 楼 jason08010 的回复:
再认真地搜了下MSDN CListCtrl有这个参数LVSIL_SMALL,CTreeCtrl没有!但就算改成LVSIL_NORMAL还是不行
请改成TVSIL_NORMAL
schlafenhamster 2014-12-17
  • 打赏
  • 举报
回复
"第二个 HIMAGELIST 必须 创建 对。" 上代码
jason08010 2014-12-17
  • 打赏
  • 举报
回复
引用 8 楼 jacksonfan 的回复:
[quote=引用 6 楼 jason08010 的回复:] 试过SetImageList(NULL, LVSIL_SMALL);,然后再设置新图像列表还是不行
Type of image list to set. The image list can be one of the following values: 第二个参数,没有你写的那个[/quote] 再认真地搜了下MSDN CListCtrl有这个参数LVSIL_SMALL,CTreeCtrl没有!但就算改成LVSIL_NORMAL还是不行
jason08010 2014-12-17
  • 打赏
  • 举报
回复
引用 8 楼 jacksonfan 的回复:
[quote=引用 6 楼 jason08010 的回复:] 试过SetImageList(NULL, LVSIL_SMALL);,然后再设置新图像列表还是不行
Type of image list to set. The image list can be one of the following values: 第二个参数,没有你写的那个[/quote] 有吧! 1.1 设置图像控制CListCtrl::SetImageList的调用格式如下: CImageList* SetImageList( CImageList* pImageList, int nImageList ); 其返回值是指向前一个图像列表控制的一个指针,如果不存在前一个图像列表则为NULL;其中参数pImageList是指向图像列表的标识,nImageList是图像列表的类型,可以是如下值: LVSIL_NORMAL 用大图标方式进行图像列表; LVSIL_SMALL 用小图标方式进行图像列表; LVSIL_STATE 以图像状态进行图像列表;
vocanicy 2014-12-17
  • 打赏
  • 举报
回复
重设SetImageList之后,再更新每个节点的图标

15,978

社区成员

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

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