HICON icon[4];
icon[0] = AfxGetApp()->LoadIcon(IDI_ICONA);
icon[1] = AfxGetApp()->LoadIcon(IDI_ICONB);
icon[2] = AfxGetApp()->LoadIcon(IDI_ICONC);
icon[3] = AfxGetApp()->LoadIcon(IDI_ICOND);
CImageList *imgList = new CImageList;
imgList->Create(16, 16, ILC_COLOR32|ILC_MASK,20, 1);//使用背景透明的位图
imgList->Add(icon[0]);
imgList->Add(icon[1]);
imgList->Add(icon[2]);
imgList->Add(icon[3]);
m_mytree.SetImageList(imgList,LVSIL_NORMAL);
//为m_mytree设置一个图像列表,使CtreeCtrl的节点显示不同的图标
m_mytree.SetBkColor(RGB(255,255,255));//设置m_mytree的背景色
m_mytree.DeleteAllItems();
m_mytree.SetTextColor(RGB(0xF5,0xFA,0xFF));
HTREEITEM RootItem =m_mytree.InsertItem("功能菜单",3,3,TVI_ROOT,TVI_LAST);//
m_InfoTree.SetBkColor(RGB(0xF5,0xFA,0xFF));
m_InfoTree.SetTextColor(RGB(0,0,0));
HTREEITEM LeafItem1 = m_mytree.InsertItem("泵站信息",2,2,RootItem,TVI_LAST);//
HTREEITEM LeafItem2 = m_mytree.InsertItem("服务器",2,2,RootItem,TVI_LAST);
HTREEITEM LeafItem3 = m_mytree.InsertItem("日志",2,2,RootItem,TVI_LAST);
m_mytree.InsertItem("日志",0,0,RootItem,TVI_LAST); 等同于m_mytree.InsertItem("日志",RootItem,TVI_LAST);
m_mytree.Expand(RootItem,TVE_EXPAND);
InsertItem()函数的第二个,第三个参数表示ICON数组中图标的索引。