CImageList m_ImageList;
m_ImageList.Create(8,8,ILC_COLOR8,2,6);
HICON my_icon1,my_icon2;
my_icon1=AfxGetApp()->LoadIcon(IDI_LOST);
my_icon2=AfxGetApp()->LoadIcon(IDI_UnLost);
m_ImageList.Add(my_icon1);
m_ImageList.Add(my_icon2);
HTREEITEM subroot2=m_TreeCtrl.InsertItem("this test",1,1,root);
m_TreeCtrl.SetItemImage(subroot2,1,1);
8 个解决方案
#1
CImageList m_ImageList;应该将这个ImageList作为对话框的成员变量才行!
#2
还有,你没有建立ImageList和TreeCtrl的关联。
CTreeCtrl::SetImageList
CImageList* SetImageList( CImageList * pImageList, int nImageListType );
=========================================================================
m_TreeCtrl.SetImageList(&m_ImageList,TVSIL_NORMAL);
CTreeCtrl::SetImageList
CImageList* SetImageList( CImageList * pImageList, int nImageListType );
=========================================================================
m_TreeCtrl.SetImageList(&m_ImageList,TVSIL_NORMAL);
#3
我连接了呀,是这个忘了写出来了,再给个完整的我的代码。
CImageList m_ImageList;
m_ImageList.Create(8,8,ILC_COLOR8,2,6);
HICON my_icon1,my_icon2;
my_icon1=AfxGetApp()->LoadIcon(IDI_LOST);
my_icon2=AfxGetApp()->LoadIcon(IDI_UnLost);
m_ImageList.Add(my_icon1);
m_ImageList.Add(my_icon2);
m_TreeCtrl.SetImageList(&m_ImageList,LVSIL_NORMAL);
HTREEITEM subroot2=m_TreeCtrl.InsertItem("this test",1,1,root);
m_TreeCtrl.SetItemImage(subroot2,1,1);
CImageList m_ImageList;
m_ImageList.Create(8,8,ILC_COLOR8,2,6);
HICON my_icon1,my_icon2;
my_icon1=AfxGetApp()->LoadIcon(IDI_LOST);
my_icon2=AfxGetApp()->LoadIcon(IDI_UnLost);
m_ImageList.Add(my_icon1);
m_ImageList.Add(my_icon2);
m_TreeCtrl.SetImageList(&m_ImageList,LVSIL_NORMAL);
HTREEITEM subroot2=m_TreeCtrl.InsertItem("this test",1,1,root);
m_TreeCtrl.SetItemImage(subroot2,1,1);
#4
可是怎么回师呢,还是没有,
m_TreeCtrl.SetImageList最后一个参数改为TVSIL_NORMAL还是不行呢?
m_TreeCtrl.SetImageList最后一个参数改为TVSIL_NORMAL还是不行呢?
#5
是成员变量吗?m_ImageList
#6
不是的,你看看我上面的代码,运行后就是不见象windows的资源管理器那样出来文件夹图象呢?
#7
你看你的图片是不是太大,或色素不支持,在资源里面看看ICON能够看见不?
#8
不是的,知道了,ImageList必须做为对话框的成员变量才行,呵呵,这是太死板了,不知道为什么呢?
#1
CImageList m_ImageList;应该将这个ImageList作为对话框的成员变量才行!
#2
还有,你没有建立ImageList和TreeCtrl的关联。
CTreeCtrl::SetImageList
CImageList* SetImageList( CImageList * pImageList, int nImageListType );
=========================================================================
m_TreeCtrl.SetImageList(&m_ImageList,TVSIL_NORMAL);
CTreeCtrl::SetImageList
CImageList* SetImageList( CImageList * pImageList, int nImageListType );
=========================================================================
m_TreeCtrl.SetImageList(&m_ImageList,TVSIL_NORMAL);
#3
我连接了呀,是这个忘了写出来了,再给个完整的我的代码。
CImageList m_ImageList;
m_ImageList.Create(8,8,ILC_COLOR8,2,6);
HICON my_icon1,my_icon2;
my_icon1=AfxGetApp()->LoadIcon(IDI_LOST);
my_icon2=AfxGetApp()->LoadIcon(IDI_UnLost);
m_ImageList.Add(my_icon1);
m_ImageList.Add(my_icon2);
m_TreeCtrl.SetImageList(&m_ImageList,LVSIL_NORMAL);
HTREEITEM subroot2=m_TreeCtrl.InsertItem("this test",1,1,root);
m_TreeCtrl.SetItemImage(subroot2,1,1);
CImageList m_ImageList;
m_ImageList.Create(8,8,ILC_COLOR8,2,6);
HICON my_icon1,my_icon2;
my_icon1=AfxGetApp()->LoadIcon(IDI_LOST);
my_icon2=AfxGetApp()->LoadIcon(IDI_UnLost);
m_ImageList.Add(my_icon1);
m_ImageList.Add(my_icon2);
m_TreeCtrl.SetImageList(&m_ImageList,LVSIL_NORMAL);
HTREEITEM subroot2=m_TreeCtrl.InsertItem("this test",1,1,root);
m_TreeCtrl.SetItemImage(subroot2,1,1);
#4
可是怎么回师呢,还是没有,
m_TreeCtrl.SetImageList最后一个参数改为TVSIL_NORMAL还是不行呢?
m_TreeCtrl.SetImageList最后一个参数改为TVSIL_NORMAL还是不行呢?
#5
是成员变量吗?m_ImageList
#6
不是的,你看看我上面的代码,运行后就是不见象windows的资源管理器那样出来文件夹图象呢?
#7
你看你的图片是不是太大,或色素不支持,在资源里面看看ICON能够看见不?
#8
不是的,知道了,ImageList必须做为对话框的成员变量才行,呵呵,这是太死板了,不知道为什么呢?