开发者

CTreeCtrl setting selected item programmatically

开发者 https://www.devze.com 2023-03-01 16:57 出处:网络
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 it

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

精彩评论

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