I want to programmatically set the state of a tree ctrl item to be selected and then process it elsewhere. I want to do this to reuse the code that is called when the user clicks it. I try this but its failing, why?
// somewhere in the code
m_tree.SetItemState(hItemToBeSelected, TVIS_SELECTED, TVIS_SELECTED);
CommonFunction()开发者_StackOverflow;
// elsewhere
CommonFunction()
{
HTREEITEM h = m_tree.GetSelectedItem();// this returns NULL.
}
How can I do this?
You want to use SelectItem instead of SetItemState: http://msdn.microsoft.com/en-us/library/w8hy20sy(v=VS.100).aspx
精彩评论