开发者

CTreeCtrl setting selected item programmatically

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜