[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 959
  • Last Modified:

CtreeCtrl's child item

I would like to have sample codes to 'SetFocus' to a particular child item of a CTreeCtrl. The child info available is its item.lParam value.

Thanx.  
0
engllf
Asked:
engllf
1 Solution
 
galkinCommented:
CTreeCtrl::SetItemState(hItem, TVIS_SELECTED, TVIF_STATE);
0
 
engllfAuthor Commented:
Hi,
As i have only the lParam value of the child item, i tried to get the hItem of the child item using the below code.  But i have problem with the GetItem() function.  It returns something that is not what i want. (I think the mask value is not set correctly.) BTW, I am using a CTreeView.

TV_ITEM TVItem ;
TVItem.lParam = (LPARAM) 1001 ; // i only know this lParam value
TVItem.mask = TVIF_PARAM ; //which flag needs to be included here?  

CTreeCtrl& MyTree = GetTreeCtrl() ;
if (MyTree.GetItem(&TVItem) ==  0)
{
    AfxMessageBox("error");
    return -1 ;
}

MyTree.SetItemState(TVItem.hItem, TVIS_SELECTED, TVIF_STATE) ;
0
 
winmeisterCommented:
This is the code you need:

SetItemState(TVItem.hItem, TVIS_DROPHILITED | TVIS_SELECTED, TVIS_DROPHILITED | TVIS_SELECTED);

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now