Author Topic: treeview recursive  (Read 2148 times)

5k3l3t0r

  • Guest
treeview recursive
« on: June 09, 2012, 04:48:37 AM »
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
« Last Edit: June 11, 2012, 04:03:45 AM by 5k3l3t0r »

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4813
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: treeview recursive
« Reply #1 on: June 10, 2012, 12:42:29 PM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

5k3l3t0r

  • Guest
Re: treeview recursive
« Reply #2 on: June 11, 2012, 04:02:43 AM »
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

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: treeview recursive
« Reply #3 on: June 11, 2012, 12:18:09 PM »
Looks good :t
Check if
Code: [Select]
         invoke SearchTreeItem,NULL,pParam,hItemChild
         mov hItmFound,eax
         .if hItmFound != NULL
            mov eax,hItmFound
            ret
         .endif
could be replaced by
Code: [Select]
         invoke SearchTreeItem,NULL,pParam,hItemChild
         mov hItmFound,eax
         .if eax
            ret
         .endif