如何实现在树形视图中各个分支的旁边显示状态(加一个彩色小圆点)

解决方案 »

  1.   


    afx_msg void OnDrawItem( int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct );
    里面写加圆点的代码
      

  2.   

    是ctreeview吗?还是ctreectrl?????
      

  3.   

    CTreeCtrl::SetImageList
    CImageList* SetImageList( CImageList * pImageList, int nImageListType );Return ValuePointer to the previous image list, if any; otherwise NULL.ParameterspImageListPointer to the image list to assign. If pImageList is NULL, all images are removed from the tree view control.nImageListTypeType of image list to set. The image list can be one of the following values: TVSIL_NORMAL   Sets the normal image list, which contains the selected and nonselected images for the tree view item.
    TVSIL_STATE   Sets the state image list, which contains the images for tree view items that are in a user-defined state. 
    要是两个都设的话就会有两个图标
      

  4.   

    CImageList Cil1,Cil2;//大小图标像列表BOOL CVCTREEDlg::OnInitDialog(){ CDialog::OnInitDialog();......//原来其它代码// TODO: Add extra initialization here// 此处开始增加代码CVCTREEApp *pApp=(CVCTREEApp *)AfxGetApp();//创建图象列表Cil1.Create(16,16,ILC_COLOR,2,2);Cil1.Add(pApp->LoadIcon(IDI_PM));Cil1.Add(pApp->LoadIcon(IDI_CJ));m_TreeCtrl.SetImageList(&Cil1,TVSIL_NORMAL); //设置图象列表DWORD dwStyles=GetWindowLong(m_TreeCtrl.m_hWnd,GWL_STYLE);//获取树控制原风格dwStyles|=TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT;SetWindowLong(m_TreeCtrl.m_hWnd,GWL_STYLE,dwStyles);//