Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

VC++ TreeView Control

  • 01-02-2002 05:04PM
    #1
    Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭


    I'm trying to add some nodes to a TreeView Control but I have absolutley no idea where to start.

    Anybody got any ideas ? MS VC++ 6.0 SP3

    Thanks for all the help with the last post


Comments

  • Closed Accounts Posts: 411 ✭✭Jay


    Tree Views are quite tedious to use in VC++.

    I have quite a lot of experience with them. Where to begin...
    First off, to add a TV to the window/dialog.

    You have to have called InitCommonControlsEx with ICC_TREEVIEW_CLASSES specified.

    To draw the window use CreateWindowEx with WC_TREEVIEW as the class name.

    To add nodes to the tree...
    Each node has a set of properties, stored in a TVITEM structure.

    Each node has parents, siblings and children.
    The control itself has one parent of all the children. This can be retrieved by calling
    HTREEITEM ParentItem = TreeView_GetRoot(hCtrl);

    You can then use TreeView_GetItem(hCtrl, &tvitem);
    to retrieve the properties of each node, including the parent node.

    Calls such as TreeView_InsertItem and TreeView_SetItem are used to insert new items and set the properties of existing nodes.

    You can traverse through the tree view by using calls such as TreeView_GetNextSibling, TreeView_GetPrevSibling, TreeView_GetParent, TreeView_GetChild.

    I think that should be enough to get you started.

    If you have any more questions, just stick them up here.


Advertisement