现在的位置: 首页 > 自动控制 > 工业·编程 > 正文

Ctreectrl +CImageList应用

2012-08-11 06:55 工业·编程 ⁄ 共 993字 ⁄ 字号 暂无评论

一、定义一个CImageList m_ImageList;

二、初始化加载图片列表:

m_ImageList.Create(18, 18, ILC_COLORDDB | ILC_MASK, 0, 1);
CBitmap camer;
CBitmap camerg;
camer.LoadBitmap(IDB_Video);
camerg.LoadBitmap(IDB_VideoGroup);
m_ImageList.Add(&camerg,RGB(192, 192, 192));
m_ImageList.Add(&camer, RGB(192, 192, 192));
m_TreeList.SetImageList(&m_ImageList,TVSIL_NORMAL);

DWORD dwStyles = GetWindowLong(m_TreeList.m_hWnd,GWL_STYLE);
dwStyles |= TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT|TVS_EDITLABELS;
SetWindowLong(m_TreeList.m_hWnd,GWL_STYLE,dwStyles);

HTREEITEM hItem,hSubItem;
  hItem = m_TreeList.InsertItem("Parent1",TVI_ROOT,TVI_LAST);
  //在根结点上添加Parent1
  hSubItem = NULL;
  hSubItem = m_TreeList.InsertItem("Child1_1",1,1,hItem,hSubItem);
  //在Parent1上添加一个子结点
  hSubItem = m_TreeList.InsertItem("Child1_2",1,1,hItem,hSubItem);
  //在Parent1上添加一个子结点,排在Child1_1后面
  hSubItem = m_TreeList.InsertItem("Child1_3",1,1,hItem,hSubItem);
m_TreeList.Expand(hItem, TVE_EXPAND);
  hItem = m_TreeList.InsertItem("Parent2",TVI_ROOT,hItem);
  hItem = m_TreeList.InsertItem("Parent3",TVI_ROOT,hItem);

给我留言

留言无头像?