News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

treeview recursive

Started by 5k3l3t0r, June 09, 2012, 04:48:37 AM

Previous topic - Next topic

5k3l3t0r

hi all,
someone have(or could point me in the right direction) a function to search a treeview recursively?
what to search isn't important i just need to go throw all items and sub items...

tkx in advance

5k3l3t0r

hutch--

5k3l3t0r,

This is an example that Tedd posted in the old forum. I have used it to design other more complex applications, its simple and clearly coded and should be useful to do what you want.

5k3l3t0r

hi hutch,

thank you very much for your time...
i have solved the problem last night...

SearchTreeItem proc searchBy:DWORD,pParam:DWORD,startItem:DWORD
   local hItem:HTREEITEM
   local hItemChild:HTREEITEM
   local hItmFound:HTREEITEM
   local itm:TV_ITEM

   push startItem
   pop hItem

   .while hItem != NULL
      push hItem
      pop itm.hItem
      push TVIF_PARAM + TVIF_CHILDREN
      pop itm._mask
      invoke SendMessage,hWdTree,TVM_GETITEM,0,addr itm
      mov eax,pParam
      .if itm.lParam == eax
         mov eax,hItem
         ret
      .elseif itm.cChildren == TRUE
         invoke SendMessage,hWdTree,TVM_GETNEXTITEM,TVGN_CHILD,hItem
         mov hItemChild,eax
         invoke SearchTreeItem,NULL,pParam,hItemChild
         mov hItmFound,eax
         .if hItmFound != NULL
            mov eax,hItmFound
            ret
         .endif
      .endif
      invoke SendMessage,hWdTree,TVM_GETNEXTITEM,TVGN_NEXT,hItem
      mov hItem,eax
      inc itmcnt
   .endw
   xor eax,eax
   ret
SearchTreeItem endp


searchBy  isn't yet implemented but is easy to guess...

tkx and bye

5k3l3t0r



jj2007

Looks good :t
Check if
         invoke SearchTreeItem,NULL,pParam,hItemChild
         mov hItmFound,eax
         .if hItmFound != NULL
            mov eax,hItmFound
            ret
         .endif

could be replaced by
         invoke SearchTreeItem,NULL,pParam,hItemChild
         mov hItmFound,eax
         .if eax
            ret
         .endif