good one for learning
ReplyWhen the second item in the list has long and enough children to extend the CherryTree both down and along, pressing the up arrow makes it constantly flicker and redraw itself until the down arrow is pressed. This means you can't get to the top item without first hiding the children of the second member.
This actually happens if the first item has enough children to go off the bottom of the screen too. When you initially double click it, it's fine, if you then move down the list, and then go back to the top, when you reach the top of the list it flickers constantly until you move down by one item. This means if you are trying to hide the children of the first item it is not possible if they go out of the bottom of the control. This problem does not occur when there are not enough children to force a vertical scroll bar to be drawn. I would love it if someone could fix this, pretty please...
ReplyTVS_HASBUTTONS | TVS_HASLINES style not working ? how can i set that stylesReply
I used your class to replace multi-select tree control from Hazlewood, while it did not work in Vista / Windows 7 with control or shift key. Your demo program worked OK, but when I could not get my program to work. It had still the same problem as with Hazlewoods control. What is the trick to get it work?
The problem seems to be that when using Unicode instead of MBCS, setting TVIS_FOCUSED attribute resets TVIS_SELECTED for current selected item. Thus for shift selection the function DoPreSelection must be corrected by adding if (m_hSelect != hItem) SetItemState( m_hSelect, TVIS_SELECTED, TVIS_SELECTED); //JP !!! after the first SetItemState call. Similarily for control key in DoAction after if (nDone == 1) add: HTREEITEM hSel = GetSelectedItem(); //added SetItemState(hItem, TVIS_FOCUSED|nState, TVIS_FOCUSED|TVIS_SELECTED); //existing if (hSel != NULL && hSel != hItem) //added SetItemState( hSel, TVIS_SELECTED, TVIS_SELECTED); //addedReply
Thanks a lot for this great control. But, (in the MFC version) when I try to load 24x24, 256 color icons using "AddItemIcon" function, it always loads in a bigger size (looks like 32x32). How to overcome this problem? P.S: I've changed SetItemHeight( 24 ) and return CSize( 24, 24 ) in the function GetSize() but still no luck.
ReplyHow can i enable the original lines and buttons? And how can i setup the TVS_SHOWSELALWAYS
ReplyI found an error when add a new item with image after deleting an item sometimes. It seems that it is caused in CCherryTree::DeleteItem, forget a phrase: m_mapItemData.RemoveKey(hItem); Is it right?
ReplyFeel cool just like eating cherry. Thank you!Reply
No SetItemData implementation. You have a Custom method however, because you chose not to sub class the the tree control you can't catch the inserts, deletes and other messages that would have made handling item data and memory management trivial. Good idea, but I have to say; poor execution.
Thanks for feedback.
Because the control is derived from CTreeControl (in MFC version) and CTreeViewCtrl (for ATL version) you can use their SetItemData / GetItemData methods or even TVM_SETITEM message. Control itself doesn't use item data for any purpose so it is completely safe.
Yes, subclassing control the way you tells could make things slightly easier however all these checks like:
TreeItemData* pData = GetCustomItemData( hItem );
if( pData == NULL )
pData = CreateCustomItemData( hItem );
couldn't be avoided in any case because user may decide to subclass existing tree control (with some items)
Reply
I tried to modify this code to support for multiple item drag n drop (with multiple item drag image keeping the indentation level) and also the item renaming but it didn't work nicely. Edit for item renaming appears somewhat shifted not exactly over the item to be renamed. and dragging the image cause paint issues. [I've enabled the hot tracking of items] Any comments... Hitesh
Reply