• Advertisement
Sign in to follow this  

Win32 TREE and item position

This topic is 3822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there! Im trying to learn win32 TREES. I want to save my tree, and for that i created this structure struct TreeApp { string ParentName; vector<string> ChildName; }; vector<TreeApp> applicationTree; now i want to be able to do something like this if(parent) applicationTree.pushBack(...name of the parent in the good format that the vector will accept) if(child) applicationTree[parent_location].ChildName.pushBack(...name of the child in good format...) for that i need the integer location of the parent soo parent_location should pe 0 or 1 or... whatever int number. Any ideea how can i find the item id of a tree item ? i hope i maked sense:) Thanks alot!

Share this post


Link to post
Share on other sites
Advertisement
This problem is not unique to Win32 - you're actually tackling a problem you'll find in other contexts as well.

Anyway, the problem lies in your definition of TreeApp. TreeApp should have a form similar to a linked list - in fact, a (noncircular) linked list is a type of tree. In TreeApp you should have a vector of not strings but of other TreeApp nodes which represent the children of that particular node. For example:


struct TreeApp {
string myName;
vector<TreeApp> children;
};


When you have this you can write code like:


TreeApp appTree;
appTree.children.pushBack(...another TreeApp...);


In the above code you dont need item IDs. If you want to find a particular tree item then you can use one of the tree-traversing algorithms.

Share this post


Link to post
Share on other sites
i made a mistake - im talking about TreeView (FORM) - i need to capture the elements and save them so i can put them back in the TreeView form on open scene. I know how to do it for a list form - but treeview form ...its a mistery for me...

Thanks again - and sorry for not being clear enough.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement