MFC How to make ctreectrl virtual?

My app displays the number of records in Hugh files stored in memory using ctreectrl

, adding that all elements take ~ 20 seconds even when used SetRedraw(False)

, so how to make it completely virtual (width, depth) ctreectrl

and how to fill it?

Edit # 1 I want to display the rendered parts of the elements extended from the start, but I don't want to store them in a tree like

Root-->
    Child1-->
        SubChile1
    Child2
    Child3

      

+3


source to share


2 answers


you don't have to add all items at the same time. you should only add top level elements with cChildren = I_CHILDRENCALLBACK

and handleWM_NOTIFY

  • c code == TVN_GETDISPINFO

    if mask & TVIF_CHILDREN

    set cChildren

    (TRUE or FALSE)
  • c code == TVN_ITEMEXPANDING

    , action == TVE_EXPAND

    - expand node - add only direct children (one level) again with cChildren = I_CHILDRENCALLBACK

and possible



  • c code == TVN_ITEMEXPANDED

    , action == TVE_COLLAPSE

    - node crash - remove all children

meaning cChildren = I_CHILDRENCALLBACK

- if you add a folder to the list, you don't need to initialize it right away (open handle, enum childs) - only when you first got it I_CHILDRENCALLBACK

(this is when your element becomes visible, but if (e.g. system32) - it has too many elements but at the beginning only a few vertices are visible, new ones start to be visible when the user scrolls down) - open folder, deterministic, it has subelements (and based on this set cChildren

) but not a complete list of it (do it only on<TVN_ITEMEXPANDING, TVE_EXPAND>

+3


source


I have no advice to make it virtual. For large tree structures I use the ability to collect the child branch only when necessary. I trap TVN_ITEMEXPANDING

So how to do it: first read the first level (root) and then collapse all root nodes and read all child nodes of the root (just 1 level deep) and fill them.

When a node expands, you already have nodes, now read the next level below the children of the expanding node.



So, you only see the extended nodes and one invisible level.

I do it this way to show all nodes that can be expanded with the + sign. All nodes without child nodes appear as leaves without it.

The second way is to not populate the string data and not let the tree load it through the callback. But the impact is small. The real problem with speed is the number of knots.

+2


source







All Articles