Ctreectrl +CImageList应用

一、定义一个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);

 

 

from:http://blog.csdn.net/wny198816/article/details/6996043

你可能感兴趣的:(image)