树控件操作整理

/** @note IDB_BITMAP_TREE 是引入的tree节点位图, 16xN的BMP CImageList m_ImgList; */ m_ImgList.Create(IDB_BITMAP_TREE,16,1,RGB(255,255,255)); /** @note void CTestTreeControlDlg::OnDestroy() { CDialog::OnDestroy(); // TODO: Add your message handler code here m_ImgList.DeleteImageList();//防止内存泄漏 } */ /** @note CTreeCtrl m_ctrlTree;//树控件生成的成员变量 */ m_ctrlTree.SetImageList(&m_ImgList,TVSIL_NORMAL); HTREEITEM hRoot1 = m_ctrlTree.InsertItem("信息1", 0, 0); m_ctrlTree.InsertItem("项1.1=XXX", 1, 1, hRoot1); m_ctrlTree.InsertItem("项1.2=XXX", 2, 2, hRoot1); m_ctrlTree.InsertItem("项1.3=XXX", 3, 3, hRoot1); //27 错误的红图标 HTREEITEM hRoot2 = m_ctrlTree.InsertItem("信息2", 0, 0); m_ctrlTree.InsertItem("项2.1=XXX", 1, 1, hRoot2); m_ctrlTree.InsertItem("项2.2=XXX", 2, 2, hRoot2); m_ctrlTree.InsertItem("项2.3=XXX", 3 + 26, 3 + 26, hRoot2); HTREEITEM hRoot3 = m_ctrlTree.InsertItem("信息3", 0, 0); m_ctrlTree.InsertItem("项3.1=XXX", 1, 1, hRoot3); m_ctrlTree.InsertItem("项3.2=XXX", 2, 2, hRoot3); m_ctrlTree.InsertItem("项3.3=XXX", 3 + 26, 3 + 26, hRoot3); m_ctrlTree.Expand(hRoot1, TVE_EXPAND); m_ctrlTree.Expand(hRoot3, TVE_EXPAND);

效果图:

你可能感兴趣的:(树控件操作整理)