如何从HTREEITEM句柄中检索lparam值 [英] How to retrive the lparam value from the HTREEITEM handle

查看:117
本文介绍了如何从HTREEITEM句柄中检索lparam值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带树控件的对话框,当单击treecontrol的任何特定节点时,该控件将数据提取到列表控件。这就是我尝试插入节点的方法。

I created a dialog with a tree control which fetches data on to a list control when clicked on any particular node of the treecontrol. This is how i tried inserting nodes.

CString *sCommonAppkey = new CString(_szApp + sIsPath);

HTREEITEM hrCommon = m_cTreeCtrl.InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM, _T("Common"), icoPlanit, icoPlanit, 0, 0, (LPARAM)(LPCTSTR)sCommonAppkey, NULL, NULL);





我尝试过:



当点击一个节点时,它被定向到事件处理程序OnTvnSelchangedExample

,数据从insertitem方法中lparam参数中指定的路径获取HTREEITEM。



What I have tried:

When clicked on a node it is being directed to the event handler "OnTvnSelchangedExample"
and the data is fetched from the path specified in "lparam" parameter in the insertitem method of HTREEITEM.

void CPSysInfoDlg::OnTvnSelchangedExample(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);

	LPARAM lp = pNMTreeView->itemNew.lParam;

	CString *sTempKey = (CString *)lp;
	CString path = sTempKey->GetBuffer();
}





我只能在事件处理程序中访问lparam值。



现在我想为整个树的数据实现搜索功能。



所以我需要迭代遍历所有Tree句柄的lparam值,以便我可以搜索树中的特定文本。

SO没有点击树的任何节点,是否有可能获得树句柄的lparam值(HTREEITEM)



I can access the lparam value only in the event handler.

Now i want to implement search functionality for the entire tree's data.

so i need the lparam value of all Tree handles sequentially by iterating through it, so that i can search for the specific text in the tree.
SO without clicking on any node of the tree, is there any possibility to get the lparam value of Tree handle(HTREEITEM)

推荐答案

参见在CTreeCtrl中找到一个项目 [ ^ ]。





以上链接使用GetItemText()搜索项目文本。要获取用户数据,请使用 CTreeCtrl :: GetItemData [ ^ ]代替甚至 CTreeCtrl :: GetItem [ ^ ]获取所有节点信息:

See Finding an Item in a CTreeCtrl[^].


The above link searches the item text using GetItemText(). To get the user data use CTreeCtrl::GetItemData[^] instead or even CTreeCtrl::GetItem[^] to get all node information:
const CString *path = (const CString *)tree.GetItemData(hRoot);
if (0 == searchString.Compare(path))
{
    // found
    return hRoot;
}



[/ EDIT]


[/EDIT]


这篇关于如何从HTREEITEM句柄中检索lparam值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆