Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

More tree checkbox frustrations

I am working with a CTreeCtrl and CTreeView that has checkboxes. When the
tree view first appears, all of the boxes are unchecked. I want the opposite--all
boxes checked. I have written a routine that steps through all the items
in the tree and calls GetTreeCtrl().SetCheck(hItem, TRUE) for each item.
I put the routine in the OnInitialUpdate function, right after the code that
populates the tree control with items.

The tree view still comes up with all boxes unchecked. I have used watches
in debug mode to verify that the routine is properly setting the check state.
I have also found that the exact same code works perfectly if I put it in
another function (OnLButtonDown). Something must be resetting the check boxes
between the time OnInitialUpdate is run and the time the tree view appears
on the screen. Can anyone tell me why this is happening, and if there is
a way to prevent it? If OnInitialUpdate is the wrong place to put the code,
then where should it go?

Thanks,
Cliff Lewis
[1061 byte] By [Cliff Lewis] at [2007-11-10 12:52:20]