先看看要實(shí)現(xiàn)的視圖:

首先,這里要選擇屬性,has buttons和line at root,否則的話,就會(huì)沒(méi)有那個(gè)加號(hào)的前置符號(hào),或者,根結(jié)點(diǎn)沒(méi)有那個(gè)符號(hào)。
其次當(dāng)然是創(chuàng)建了,下面的代碼說(shuō)明了一切:
m_imagelist.Create(16,16,ILC_COLOR24|ILC_MASK,1,0);
m_imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON4));
m_imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
m_imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON2));
m_imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON3));
m_testctrl.SetImageList(&m_imagelist,TVSIL_NORMAL);
HTREEITEM root,root1,root2,root3;
root = m_testctrl.InsertItem("年級(jí)",0,0);
root1 = m_testctrl.InsertItem("一年級(jí)",1,1,root);
root2 = m_testctrl.InsertItem("二年級(jí)",2,2,root);
root3 = m_testctrl.InsertItem("三年級(jí)",3,3,root);

m_testctrl.InsertItem("張三",root1);
m_testctrl.InsertItem("李四",root2);
m_testctrl.InsertItem("王五",root3);

先創(chuàng)建一個(gè)一級(jí)目錄root,然后就是在一級(jí)目錄下創(chuàng)建二級(jí)目錄,此時(shí)創(chuàng)建的過(guò)程中調(diào)用的函數(shù)參數(shù)最后一個(gè)就是那個(gè)前一級(jí)目錄。
然后需要插入三級(jí)目錄,就是再次上一級(jí)目錄的形式。。。。
具體的資料,見(jiàn)MSDN。。
posted on 2010-02-08 15:08
deercoder 閱讀(868)
評(píng)論(1) 編輯 收藏 引用