Mfc CTreeCtrl以编程方式设置选定项
我想以编程方式设置要选择的树ctrl项的状态,然后在其他地方处理它。我想这样做是为了重用用户单击时调用的代码。我试过了,但失败了,为什么Mfc CTreeCtrl以编程方式设置选定项,mfc,tree,Mfc,Tree,我想以编程方式设置要选择的树ctrl项的状态,然后在其他地方处理它。我想这样做是为了重用用户单击时调用的代码。我试过了,但失败了,为什么 // somewhere in the code m_tree.SetItemState(hItemToBeSelected, TVIS_SELECTED, TVIS_SELECTED); CommonFunction(); // elsewhere CommonFunction() { HTREEITEM h = m_tree.GetSelectedI
// somewhere in the code
m_tree.SetItemState(hItemToBeSelected, TVIS_SELECTED, TVIS_SELECTED);
CommonFunction();
// elsewhere
CommonFunction()
{
HTREEITEM h = m_tree.GetSelectedItem();// this returns NULL.
}
如何执行此操作?您想使用SelectItem而不是SetItemState: