Click here to Skip to main content
Click here to Skip to main content

Tree control templates

By , 11 Jun 2001
 

Sample Image - TreeControlTemplates.gif

Introduction

These templates allow CTreeCtrl derived classes programmers to add three basic functionalities to their classes:

  • Iteration of all the items in the control
  • Persistence of the status of the control (when you reload it, it tries to return to its previous state)
  • Expand / Collapse all the items in the tree

Sample Code 1: Deep Iteration

/////////////////////////
// Deep iteration sample

mc_tcTree.Initialize(true);

HTREEITEM hItem= mc_tcTree.GetNext();

while (hItem != NULL)
{
    TRACE(mc_tcTree.GetItemText(hItem) + "\n");

    hItem= mc_tcTree.GetNext();
}

Sample Code 2: Width Iteration

/////////////////////////
// Width iteration sample

mc_tcTree.Initialize(false);

HTREEITEM hItem= mc_tcTree.GetNext();

while (hItem != NULL)
{
    TRACE(mc_tcTree.GetItemText(hItem) + "\n");

    hItem= mc_tcTree.GetNext();
}

Sample Code 3: Expanding All Items

/////////////////////////
// Items expand sample

mc_tcTree.SetRedraw(FALSE);
	
mc_tcTree.ExpandItem();
	
 mc_tcTree.SetRedraw(TRUE);

Sample Code 4: Collapsing All Items

/////////////////////////
// Items collapse sample

mc_tcTree.SetRedraw(FALSE);
	
mc_tcTree.ExpandItem(TVI_ROOT, TVE_COLLAPSE);
	
mc_tcTree.SetRedraw(TRUE);

Sample Code 5: Status Preservation

/////////////////////////
// Status preservation sample

mc_tcTree.SaveStatus();

PopulateTree();

mc_tcTree.RestoreStatus();

That's all folks!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

fjosesen
Web Developer
Spain Spain
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questionhow to change content of nodesmemberVenkata Ramana9-Aug-01 18:54 
Sir,
 
I am working as Associative Consultancy Trainee, in Iridium Interactive,hyderabad,india.
I have downloaded treeview code developed by "Francisco José Sen del Prado".But i don't know how to use it, to my own purpose.Please send information to change content of nodes and child nodes in treeview code.
 
regards,
Venkata Ramana.B
Accociative Consultancy Tainee,
Iridium Interactive Ltd,
iridiuminteractive.com
Hyderabad,
India.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130617.1 | Last Updated 12 Jun 2001
Article Copyright 2001 by fjosesen
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid