how to remove "+" before a tree node

hi,

My project is built on windows mobile 5.0 pocket pc,vs2005.I use the following code insert a tree node:
   TVINSERTSTRUCT InsertStruct;
   InsertStruct.hParent  = hParent; 
   InsertStruct.hInsertAfter = TVI_LAST;
   InsertStruct.item.mask =  TVIF_TEXT |TVIF_IMAGE |TVIF_CHILDREN;           
   InsertStruct.item.pszText = FileData.cFileName; 
   InsertStruct.item.iImage = 0;
   InsertStruct.item.cChildren = 1;
   InsertItem(&InsertStruct);
That's to say, all the insert nodes have children and so have "+" before them.
But now I need to remove "+" before them ,and I used SetItem function to remove it but the function just delete its children.

Any suggestion on how to remove "+" is appreciated.

Para


Answer this question

how to remove "+" before a tree node

  • Amanda Song

    Hmmm...

    I'm sure your control has the TVS_HASBUTTONS style set Have you tried to use a parent callback instead of setting zero or one in the cChildren member

    I assume you are using cChildren = 0 when using SetItem, aren't you



  • Winterset

    Yes, you're right,the tree has TVS_HASBUTTONS style and I use the following code to remove "+":
      TVITEM item  = { 0 };
      item.mask  = TVIF_HANDLE | TVIF_CHILDREN;
      item.hItem  = hRoot ;
      item.cChildren = 0;
      SetItem( &item );
    But I can't understand what you say,how to use a parent callback


  • Morias

    The following is the code:
      TV_DISPINFO tvdi;
      tvdi.item.mask   = TVIF_CHILDREN ;         
      tvdi.item.hItem   = hCurrent;
      GetItem(&tvdi.item);
      tvdi.item.cChildren = 0;
      SetItem(&tvdi.item);
      
      HWND hWndParent;
      hWndParent = ::GetParent(m_hWnd);
      if(hWndParent)
      {
       tvdi.hdr.hwndFrom = m_hWnd;
       tvdi.hdr.idFrom  = GetDlgCtrlID(m_hWnd);
       tvdi.hdr.code  = TVN_GETDISPINFO;
       SendMessage(hWndParent, WM_NOTIFY, tvdi.hdr.idFrom,
           (LPARAM)&tvdi);
      }
    that's to say ,first set the item's cChildren equal 0,and then send message to its parent  to remove "+" .

  • RonaldS

    That's great! Could you post the solution or a link to the solution here This way, we can build FAQS, so other people can benefit from it too!

  • Tim Heckel

    Excellent! I've marked it as answered so people can see for themselves.

  • Sondre - MSFT Regional Director

    I have to say I'm not familiair with the CE SDK, but the help suggests to use I_CHILDRENCALLBACK for the cChildren member. This callback lets you dynamically tell if the member contains children.

    I_CHILDRENCALLBACK The parent window keeps track of whether the item has child items. In this case, when the tree view control needs to display the item, the control sends the parent a TVN_GETDISPINFO message to determine whether the item has child items.

    Or is this not supported on CE

  • LCoder

    Thank U very much.
    I have tried I_CHILDRENCALLBACK in my project and it doesn't work too,but I find some valuable infomation in the internet with  the keyword "I_CHILDRENCALLBACK" ,and now the problem is not a  problem.

    Para


  • how to remove "+" before a tree node