Q: How to use CTreeCtrl's TVSIL_STATE flag in SetImageList
wang shao yu -- wsy@pub.zjpta.net.cn Tuesday, December 24, 1996 Environment: VC++ 4.2-flat, Win 95 Hi friends, I am using a CTreeView object in my application. I want the tree ctrl items can use different images when it is expanded or collapsed. I noticed there is a TVSIL_STATE flag in SetImageList. I guess it can determine which image to be used when an item is expanded or ollapsed. But I dont know how to use it. I looked at some samples but could not find useful information. Could you give me any guides? I have tried SetImageState() without success. Thanks in advance and MERRY CHRISTMAS! -- Truly yours, Yong Xu, wsy@pub.zjpta.net.cn, Hangzhou, P.R.C
wang shao yu -- wsy@pub.zjpta.net.cn Thursday, January 02, 1997 Environment: VC++ 4.2-flat, Win 95 Hi there, I am using a CTreeView object in my application. I want the tree ctrl items can use different images when it is expanded or collapsed. I tried to use TVSIL_STATE flag in SetImageList. However, what I get is an additional icon besides the original selected/unselected icon when the item is expanded. I dont need selected/unselected icons, I just need expanded/collapsed icons with my parent items. Here are part of my codes: //In tree view's OnInitialUpdate(), I set the image list void CMyTreeView::OnInitialUpdate() { CTreeView::OnInitialUpdate(); CTreeCtrl& treeCtrl = GetTreeCtrl(); //Set the tree ctrl style ModifyStyle(0, TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS |TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP); //cx=16, cy=15, 4 grow, white is mask //m_il is a CImageList member variable in the CMyTreeView m_il.Create(IDB_TREEIMAGES, 16, 4, RGB(255, 255, 255)); treeCtrl.SetImageList(&m_il, TVSIL_NORMAL); treeCtrl.SetImageList(&m_il, TVSIL_STATE); ... } //In tree view's TVN_ITEMEXPANDED handler OnItemexpanded void CCcuisineView::OnItemexpanded(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; CTreeCtrl& treeCtrl = GetTreeCtrl(); if (pNMTreeView->action == TVE_EXPAND) //set icon to the second one in the imagelist treeCtrl.SetItemState(pNMTreeView->itemNew.hItem, INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK); else //set icon to the first one in the imagelist treeCtrl.SetItemState(pNMTreeView->itemNew.hItem, INDEXTOSTATEIMAGEMASK(0), TVIS_STATEIMAGEMASK); *pResult = 0; }// OnItemexpanded(NMHDR* pNMHDR, LRESULT* pResult) I looked at some samples but could not find useful information. Could you give me any guides? Thanks in advance! -- Truly, Yong Xu, wsy@pub.zjpta.net.cn, Hangzhou, P.R.C
Dong Chen -- d_chen@ix.netcom.com Thursday, January 02, 1997 Take a look at the sample Rowlist which presents how to set the state flag for the imagelist for the list control. You should be able to get some ideas for what you want to accomplish. -- Dong d_chen@ix.netcom.com
| Вернуться в корень Архива |