this->m_MyFont.CreateFont(12,0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, GB2312_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,DEFAULT_PITCH | FF_SWISS,_T("Arial"));
CImageList m_ImagesList;
m_ImagesList.Create(16,16,ILC_COLOR24,0,8);
CBitmap bmp;
bmp.LoadBitmap(IDB_LEFT);
m_ImagesList.Add(&bmp, RGB(0,0,0));
HTREEITEM root0=theTree.InsertItem("",0,1,TVI_ROOT,TVI_LAST);
HTREEITEM root=theTree.InsertItem("StreamDown",3,3,TVI_ROOT,TVI_LAST);
theTree.InsertItem("Downloading",3,3,root,TVI_LAST);
theTree.InsertItem("Downloaded",4,4,root,TVI_LAST);
theTree.InsertItem("Deleted",5,5,root,TVI_LAST);
theTree.Expand(root,TVE_EXPAND);//此根节点默认展开
//theTree.SetBkColor(RGB(255,0,0));
theTree.SetImageList(&m_ImagesList,TVSIL_NORMAL);
响应=TVN_SELCHANGED消息
OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
CTreeCtrl& theTree = GetTreeCtrl();
CString strCation = theTree.GetItemText(pNMTreeView->itemNew.hItem);
strCation.MakeLower();
int nIndex;
if (strCation == "downloaded")
{
nIndex = 1;
}
else if(strCation == "deleted")
{
nIndex = 2;
}
else
{
nIndex = 0;
}
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
pMainFrame->TreeSelectItemChanged(nIndex);
*pResult = 0;
}