Are you sure hParentItem is a valid tree item handle of an item already
inserted?
Have you redrawn the tree control?
--
Andy Hassall (an...@andyh.org) icq(5747695) http://www.andyh.org
http://www.andyh.uklinux.net/space - disk usage analysis tool
I get a similar problem using CTreeCtrl::InsertItem(LPTVINSERTSTRUCT):
When inserting two items using this function (a parent and a child
item), the child is not displayed (although a valid handle is returned)
and the parent seems to be childless.
(Environment: VC++6, W2K SP1)
When using the overload function CTreeCtrl::InsertItem(UINT nMask,
LPCTSTR lpszItem, ...) everything works just fine.
I worked around this problem by setting the parent's children flag
manually after inserting a child item:
TVITEM tvitem;
memset(&tvitem, 0, sizeof(TVITEM));
tvitem.hItem = hParentItem;
tvitem.mask = TVIF_CHILDREN;
tvitem.cChildren = 1;
m_tree.SetItem(&tvitem);
It's also possible to set cChildren in each item's TVITEM structure to
I_CHILDRENCALLBACK, but then you will have to handle the
TVN_GETDISPINFO message to tell the tree control if an item has
children or not. If you don't handle the message, the item will appear
to have children even if it's childless, but you can't expand the
branch.
Sent via Deja.com
http://www.deja.com/