Re: Tree Expand

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

Thanks so much for replying. I've posted in the section you've suggested.

"Simon Trew" wrote:

> "victorsk" <victorsk@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:2084D75E-6C85-49E6-A49A-57B9D8B10066@xxxxxxxxxxxxxxxx
> > Hello,
> >
> > I am puzzled on as to why the Expand function is not working in my
> > program.
> > What I have is a function that calls generic Expand() function of
> > CTreeCtrl.
> > Here,
> > my_tree member variable came from:
> >
> > cn_tree ctr_tree; //from class cn_tree : public CTreeCtrl
> > cn_tree* my_tree;
> > my_tree = &ctr_tree; //because ctr_tree handles controls
> >
> > then I populate my_tree->PopulateTree(connect, some_string);
> > and here is the problem:
> > Onclick OnTree() is invoked
> > void cedlg1::OnTree()
> > {
> > HTREEITEM hItem_s = my_tree->GetSelectedItem();
> > if (hItem_s != NULL)
> > {
> > //** Expand not working **
> > my_tree->Expand(hItem_s, TVE_EXPAND);
> > my_tree->EnsureVisible(hItem_s);
> > }
> > }
>
> Have yoy checked that hItem_s is in fact not NULL? Why do you think the item
> is selected? If you click on the + rather than on the item text, it will not
> necessarily be selected. You should use the CTreeCtrl::HitTest function to
> determine where the click took place, passing in the co-ordinatres you
> received as parameters to the OnClick method.
>
> Since this is specific to MFC, you may get better results by posting in
> microsoft.public.vc.mfc.
>
> S.
>
>
>
.