When 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.
Posted by hi1
on 07/15/2010 09:25am
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...
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?
Posted by JarmoP
on 04/16/2010 06:04am
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); //added
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.
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.
Posted by Fahrenheit
on 06/09/2005 03:20am
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)
Help needed to support for multiple item drag n drop image and item renaming
Posted by hitesh17
on 05/09/2005 09:36am
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]