我想以编程方式设置要选择的树形按钮项目的状态,然后在别处处理它。我想这样做,以重用用户点击它时调用的代码。我尝试这个,但它的失败,为什么?CTreeCtrl以编程方式设置选定的项目
// somewhere in the code
m_tree.SetItemState(hItemToBeSelected, TVIS_SELECTED, TVIS_SELECTED);
CommonFunction();
// elsewhere
CommonFunction()
{
HTREEITEM h = m_tree.GetSelectedItem();// this returns NULL.
}
我该怎么做?
感谢