zapper222

Dialog based MFC app.
I am attempting to update a tree control with checkmarks so that on initialization all tree items are checked.
I am trying a loop in the OnInitDialog() looking something like this:

for( k=0;k<j;k++)
m_Property.SetCheck(hTreeItem[k]);
if(m_Property.ItemHasChildren(hTreeItem[k])){
HTREEITEM hNextItem;
HTREEITEM hChildItem = m_Property.GetChildItem(hTreeItem[k]);
while (hChildItem != NULL){
hNextItem = m_Property.GetNextItem(hChildItem, TVGN_NEXT);
m_Property.SetCheck(hChildItem);
hChildItem = hNextItem;
}
}
}
Unfortunately it doesn't work.....anyone know why


Re: Visual C++ Language Initialization of check marks in a treeview

Sdi

Did you turn on TVS_CHECKBOXES like the documentation says I.e. after you create the tree control but before you populate it with nodes



Re: Visual C++ Language Initialization of check marks in a treeview

zapper222

No..I only set it using the Resource Editor.....I would have thought that would be enough.....
Setting and unsetting the checkmarks works fine once the program is running.....its only when I initialize where it seems to ignore the command.




Re: Visual C++ Language Initialization of check marks in a treeview

Bite Qiu - MSFT

Using the resource editor should be fine, it worth nothing to be different from programmatically set the checkbox style. you need to check the return value and see if it has been called correctlly, for the example and other information, please look at: http://msdn2.microsoft.com/en-us/library/h1w2w3b3(VS.71).aspx