[help]More tips about PtTree?

I put a PtTree in a dialog and change it’s items periodically.

  1. When I close the dialog and reopen it, how can I keep the content of
    the tree as same as it’s last content(when dialog is closed)?
    The fact is when I close the dialog, even if the items of the tree are
    declared as global, program as followed will run into memory error:
    items_=PtTreeModifyItemString(tree,items,newstring);
    what’s the problem? Is that means if the tree is destroyed, it’s items
    are also destroyed?
    2.How to remove a item from the tree like the File Manager does? Is
    there any existing direct functions can I utilize?
    3.How does PtTreeGetCurrent work? If there’s no select item,
    PtTreeGetCurrent will return NULL even though there’re many items in the
    tree?
    Thanks a lot for your kindly help!_

“johnsonyoung” <johnsonyoung2002@yahoo.com.cn> wrote in message
news:4258FAD3.9080706@yahoo.com.cn

I put a PtTree in a dialog and change it’s items periodically.

  1. When I close the dialog and reopen it, how can I keep the content of
    the tree as same as it’s last content(when dialog is closed)?

You could remove the items from the widget before the widget is destroyed,
and put them back in when the widget is created again.

The fact is when I close the dialog, even if the items of the tree are
declared as global, program as followed will run into memory error:
items> =PtTreeModifyItemString(tree,items> ,newstring);
what’s the problem? Is that means if the tree is destroyed, it’s items are
also destroyed?

Yes. When you destroy a PtTree widgets, it frees all the items in it.

2.How to remove a item from the tree like the File Manager does? Is there
any existing direct functions can I utilize?

You mean like PtTreeRemoveItem(), PtTreeRemoveList(), and
PtTreeRemoveChildren()?

3.How does PtTreeGetCurrent work? If there’s no select item,
PtTreeGetCurrent will return NULL even though there’re many items in the
tree?

In the default mode, the current item is usually selected, but “selected”
and “current” are two different concepts. The current item is the item that
the widget draws the blue line around when it has focus. You can think of
it as “the item that has focus”. You can use the Ctrl key to navigate
around the tree items without changing the selection, and then hit the space
bar to select (or, in some modes, unselect) the current item. Or hit the
left arrow key to collapse the subtree or jump to the parent item. And so
on.

If you add items to an empty tree widget and none of them is flagged as the
current item, there’s no current item until the widget gets focus. When the
widget gets focus and there’s no current item, it makes the first item the
current item. Depending on the selection mode, the item may also get
selected.