Click to See Complete Forum and Search --> : CTreeCtrl


Essam Helmy
May 16th, 1999, 09:12 AM
Hi,
I insert objects address as lParam in CTreeList and when I try to get it at OnDblclk.
by this code

NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
TVITEMA* pItemNew = &pNMTreeView->itemNew;
CCityOb* pCity = (CCityOb*) pItemNew->lParam;

pCity don't return as vaild object, any one can help me
thanks.

Sergio Acosta
May 29th, 1999, 06:10 PM
I had the same problem.
This is a little tricky but works:


OnItemDoubleClick()
{
HTREEITEM item;
item = m_Tree.GetSelectedItem();

//...
}




This way you can know the item by text using


CString ItemText = m_Tree.GetItemText(item)




but i don't remember if the HTREEITEM structure allows you to get the index.

Hope it helps.

May 30th, 1999, 02:46 AM
how do you poke the data in there?

Yogen M
May 30th, 1999, 11:21 PM
When inserting the item in the control use this

CCityOb* pCity = new CCityOb;
//call any methods or initialize CCityOb
//and then
...->lParam = pCity;



where lParam is from the item u r inserting.