如何在TreeList中加图标?
35. 如何在TreeList中加图标?
[问题提出]
请问treeview控件和treectrl控件的用法有何不同呢?向如何imagelist控件中加图象呀?
[解决方法]
1)
HICON hicon[8];
m_imageList.Create(16,16,0,8,8);
hicon[0]=AfxGetApp()->LoadIcon(IDI_ICON0);
hicon[1]=AfxGetApp()->LoadIcon(IDI_ICON1);
hicon[2]=AfxGetApp()->LoadIcon(IDI_ICON2);
hicon[3]=AfxGetApp()->LoadIcon(IDI_ICON3);
hicon[4]=AfxGetApp()->LoadIcon(IDI_ICON4);
hicon[5]=AfxGetApp()->LoadIcon(IDI_ICON5);
hicon[6]=AfxGetApp()->LoadIcon(IDI_ICON6);
hicon[7]=AfxGetApp()->LoadIcon(IDI_ICON7);
for(int n=0;n<8;n++)
m_imageList.Add(hicon[n]);
CTreeCtrl *pTree=(CTreeCtrl *)GetDlgItem(IDC_TREE);
pTree->SetImageList(&m_imageList,TVSIL_NORMAL);
2)
CImageList cil1;
cil1.Create(32,32,TRUE,2,2);
cil1.Add(pApp->LoadIcon(IDI_DAO1));
cil1.Add(pApp->LoadIcon(IDI_DAO2));
cil1.Add(pApp->LoadIcon(IDI_DAO3));
cil1.Add(pApp->LoadIcon(IDI_DAO4));
cil1.Add(pApp->LoadIcon(IDI_DAO5));
cil1.Add(pApp->LoadIcon(IDI_DAO6));
cil1.Add(pApp->LoadIcon(IDI_DAO7));
cil1.Add(pApp->LoadIcon(IDI_DAO8));
cil1.Add(pApp->LoadIcon(IDI_DAO9));
//设置图象列表
m_list.SetImageList(&cil1,LVSIL_NORMAL);
[问题提出]
请问treeview控件和treectrl控件的用法有何不同呢?向如何imagelist控件中加图象呀?
[解决方法]
1)
HICON hicon[8];
m_imageList.Create(16,16,0,8,8);
hicon[0]=AfxGetApp()->LoadIcon(IDI_ICON0);
hicon[1]=AfxGetApp()->LoadIcon(IDI_ICON1);
hicon[2]=AfxGetApp()->LoadIcon(IDI_ICON2);
hicon[3]=AfxGetApp()->LoadIcon(IDI_ICON3);
hicon[4]=AfxGetApp()->LoadIcon(IDI_ICON4);
hicon[5]=AfxGetApp()->LoadIcon(IDI_ICON5);
hicon[6]=AfxGetApp()->LoadIcon(IDI_ICON6);
hicon[7]=AfxGetApp()->LoadIcon(IDI_ICON7);
for(int n=0;n<8;n++)
m_imageList.Add(hicon[n]);
CTreeCtrl *pTree=(CTreeCtrl *)GetDlgItem(IDC_TREE);
pTree->SetImageList(&m_imageList,TVSIL_NORMAL);
2)
CImageList cil1;
cil1.Create(32,32,TRUE,2,2);
cil1.Add(pApp->LoadIcon(IDI_DAO1));
cil1.Add(pApp->LoadIcon(IDI_DAO2));
cil1.Add(pApp->LoadIcon(IDI_DAO3));
cil1.Add(pApp->LoadIcon(IDI_DAO4));
cil1.Add(pApp->LoadIcon(IDI_DAO5));
cil1.Add(pApp->LoadIcon(IDI_DAO6));
cil1.Add(pApp->LoadIcon(IDI_DAO7));
cil1.Add(pApp->LoadIcon(IDI_DAO8));
cil1.Add(pApp->LoadIcon(IDI_DAO9));
//设置图象列表
m_list.SetImageList(&cil1,LVSIL_NORMAL);
上一篇:std::find,std::find_if使用小结
下一篇:MFC Telnet Application(mfc telnet 端口,代码实现、不调用telnet.exe)