What is the point of CountTreeViewNodes() if you can't get the tree view nodes from the parent?
TreeViews are kind of useless
BlitzPlus Forums/BlitzPlus Programming/TreeViews are kind of useless Link to MS docs:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/treeview/messages/tvm_getnextitem.asp
Constants:
Example code:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/treeview/messages/tvm_getnextitem.asp
Constants:
Const TV_FIRST = $1100 Const TVM_GETNEXTITEM = TV_FIRST + 10 Const TVM_GETITEMSTATE = TV_FIRST + 39 Const TVIS_EXPANDED = $20 Const TVGN_CARET = $9 ;Const WC_TREEVIEW32A "SysTreeView32" ;Const WC_TREEVIEW32W L"SysTreeView32" ;Const WC_TREEVIEW WINELIB_NAME_AW(WC_TREEVIEW) Const TVSIL_NORMAL =0 Const TVSIL_STATE =2 ;Const TV_FIRST =$1100 Const TVM_INSERTITEM32A =(TV_FIRST+0) Const TVM_INSERTITEM32W =(TV_FIRST+50) ;Const TVM_INSERTITEM =WINELIB_NAME_AW(TVM_INSERTITEM) Const TVM_DELETEITEM =(TV_FIRST+1) Const TVM_EXPAND =(TV_FIRST+2) Const TVM_GETITEMRECT =(TV_FIRST+4) Const TVM_GETCOUNT =(TV_FIRST+5) Const TVM_GETINDENT =(TV_FIRST+6) Const TVM_SETINDENT =(TV_FIRST+7) Const TVM_GETIMAGELIST =(TV_FIRST+8) Const TVM_SETIMAGELIST =(TV_FIRST+9) ;Const TVM_GETNEXTITEM =(TV_FIRST+10) Const TVM_SELECTITEM =(TV_FIRST+11) Const TVM_GETITEM32A =(TV_FIRST+12) Const TVM_GETITEM32W =(TV_FIRST+62) ;Const TVM_GETITEM =WINELIB_NAME_AW(TVM_GETITEM) Const TVM_SETITEM32A =(TV_FIRST+13) Const TVM_SETITEM32W =(TV_FIRST+63) ;Const TVM_SETITEM =WINELIB_NAME_AW(TVM_SETITEM) Const TVM_EDITLABEL32A =(TV_FIRST+14) Const TVM_EDITLABEL32W =(TV_FIRST+65) ;Const TVM_EDITLABEL =WINELIB_NAME_AW(TVM_EDITLABEL) Const TVM_GETEDITCONTROL =(TV_FIRST+15) Const TVM_GETVISIBLECOUNT =(TV_FIRST+16) Const TVM_HITTEST =(TV_FIRST+17) Const TVM_CREATEDRAGIMAGE =(TV_FIRST+18) Const TVM_SORTCHILDREN =(TV_FIRST+19) Const TVM_ENSUREVISIBLE =(TV_FIRST+20) Const TVM_SORTCHILDRENCB =(TV_FIRST+21) Const TVM_ENDEDITLABELNOW =(TV_FIRST+22) Const TVM_GETISEARCHSTRING32A =(TV_FIRST+23) Const TVM_GETISEARCHSTRING32W =(TV_FIRST+64) ;Const TVM_GETISEARCHSTRING =WINELIB_NAME_AW(TVM_GETISEARCHSTRING) Const TVM_SETTOOLTIPS =(TV_FIRST+24) Const TVM_GETTOOLTIPS =(TV_FIRST+25) Const TVM_SETINSERTMARK =(TV_FIRST+26) Const TVM_SETITEMHEIGHT =(TV_FIRST+27) Const TVM_GETITEMHEIGHT =(TV_FIRST+28) Const TVM_SETBKCOLOR =(TV_FIRST+29) Const TVM_SETTEXTCOLOR =(TV_FIRST+30) Const TVM_GETBKCOLOR =(TV_FIRST+31) Const TVM_GETTEXTCOLOR =(TV_FIRST+32) Const TVM_SETSCROLLTIME =(TV_FIRST+33) Const TVM_GETSCROLLTIME =(TV_FIRST+34) Const TVM_SETINSERTMARKCOLOR =(TV_FIRST+37) Const TVM_GETINSERTMARKCOLOR =(TV_FIRST+38) ;Const TVM_SETUNICODEFORMAT =CCM_SETUNICODEFORMAT ;Const TVM_GETUNICODEFORMAT =CCM_GETUNICODEFORMAT Const TVN_FIRST =-400 Const TVN_LAST =-499 Const TVN_SELCHANGING =(TVN_FIRST-1) Const TVN_SELCHANGED =(TVN_FIRST-2) Const TVN_GETDISPINFO =(TVN_FIRST-3) Const TVN_SETDISPINFO =(TVN_FIRST-4) Const TVN_ITEMEXPANDING =(TVN_FIRST-5) Const TVN_ITEMEXPANDED =(TVN_FIRST-6) Const TVN_BEGINDRAG =(TVN_FIRST-7) Const TVN_BEGINRDRAG =(TVN_FIRST-8) Const TVN_DELETEITEM =(TVN_FIRST-9) Const TVN_BEGINLABELEDIT =(TVN_FIRST-10) Const TVN_ENDLABELEDIT =(TVN_FIRST-11) Const TVN_KEYDOWN =(TVN_FIRST-12) Const TVN_GETINFOTIPA =(TVN_FIRST-13) Const TVN_GETINFOTIPW =(TVN_FIRST-14) Const TVN_SINGLEEXPAND =(TVN_FIRST-15) Const TVN_SELCHANGINGW =(TVN_FIRST-50) Const TVN_SELCHANGEDW =(TVN_FIRST-51) Const TVN_GETDISPINFOW =(TVN_FIRST-52) Const TVN_SETDISPINFOW =(TVN_FIRST-53) Const TVN_ITEMEXPANDINGW =(TVN_FIRST-54) Const TVN_ITEMEXPANDEDW =(TVN_FIRST-55) Const TVN_BEGINDRAGW =(TVN_FIRST-56) Const TVN_BEGINRDRAGW =(TVN_FIRST-57) Const TVN_DELETEITEMW =(TVN_FIRST-58) Const TVN_BEGINLABELEDITW =(TVN_FIRST-59) Const TVN_ENDLABELEDITW =(TVN_FIRST-60) Const TVIF_TEXT =$0001 Const TVIF_IMAGE =$0002 Const TVIF_PARAM =$0004 Const TVIF_STATE =$0008 Const TVIF_HANDLE =$0010 Const TVIF_SELECTEDIMAGE =$0020 Const TVIF_CHILDREN =$0040 Const TVIF_INTEGRAL =$0080 Const TVIF_DI_SETITEM =$1000 Const TVI_ROOT =-65536 Const TVI_FIRST =-65535 Const TVI_LAST =-65534 Const TVI_SORT =-65533 Const TVIS_FOCUSED =$0001 Const TVIS_SELECTED =$0002 Const TVIS_CUT =$0004 Const TVIS_DROPHILITED =$0008 Const TVIS_BOLD =$0010 ;Const TVIS_EXPANDED =$0020 Const TVIS_EXPANDEDONCE =$0040 Const TVIS_OVERLAYMASK =$0f00 Const TVIS_STATEIMAGEMASK =$f000 Const TVIS_USERMASK =$f000 Const TVHT_NOWHERE =$0001 Const TVHT_ONITEMICON =$0002 Const TVHT_ONITEMLABEL =$0004 Const TVHT_ONITEMINDENT =$0008 Const TVHT_ONITEMBUTTON =$0010 Const TVHT_ONITEMRIGHT =$0020 Const TVHT_ONITEMSTATEICON =$0040 Const TVHT_ONITEM =$0046 Const TVHT_ABOVE =$0100 Const TVHT_BELOW =$0200 Const TVHT_TORIGHT =$0400 Const TVHT_TOLEFT =$0800 Const TVS_HASBUTTONS =$0001 Const TVS_HASLINES =$0002 Const TVS_LINESATROOT =$0004 Const TVS_EDITLABELS =$0008 Const TVS_DISABLEDRAGDROP =$0010 Const TVS_SHOWSELALWAYS =$0020 Const TVS_RTLREADING =$0040 Const TVS_NOTOOLTIPS =$0080 Const TVS_CHECKBOXES =$0100 Const TVS_TRACKSELECT =$0200 Const TVS_SINGLEEXPAND =$0400 Const TVS_INFOTIP =$0800 Const TVS_FULLROWSELECT =$1000 Const TVS_NOSCROLL =$2000 Const TVS_NONEVENHEIGHT =$4000 Const TVS_SHAREDIMAGELISTS =$0000 Const TVS_PRIVATEIMAGELISTS =$0400 Const TVE_COLLAPSE =$0001 Const TVE_EXPAND =$0002 Const TVE_TOGGLE =$0003 Const TVE_EXPANDPARTIAL =$4000 Const TVE_COLLAPSERESET =$8000 Const TVGN_ROOT =0 Const TVGN_NEXT =1 Const TVGN_PREVIOUS =2 Const TVGN_PARENT =3 Const TVGN_CHILD =4 Const TVGN_FIRSTVISIBLE =5 Const TVGN_NEXTVISIBLE =6 Const TVGN_PREVIOUSVISIBLE =7 Const TVGN_DROPHILITE =8 ;Const TVGN_CARET =9 Const TVGN_LASTVISIBLE =10 Const TVC_UNKNOWN =$00 Const TVC_BYMOUSE =$01 Const TVC_BYKEYBOARD =$02
Example code:
Get the windows handle of the first tree view node: node=SendMessage(QueryObject(tree,1), TVM_GETNEXTITEM, TVGN_CHILD, 0) Get a sibling: sibnode=SendMessage(QueryObject(tree,1), TVM_GETNEXTITEM, TVGN_NEXT,node)
I've just turned it into a new bit of code I made, a directory view:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Directory View - Made By Lattyware ;;; ;;; //www.lattyware.com\\ ;;; ;;; Note this is not a gadget, just a function (or two). ;;; ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; CreateDirectoryView(group,directory,x,y,width,height,viewfiles) ;;; ;;; ;;; ;;; Paramaters: ;;; ;;; group - A group gadget handle. ;;; ;;; directory - The directory to dig down from ;;; ;;; x,y,width,height - shape of the gadget. ;;; ;;; viewfiles - True to view files and folders, False for just folders. ;;; ;;; ;;; ;;; Description: ;;; ;;; Creates a directory browser. ;;; ;;; ;;; ;;; Example: ;;; ;;; ;;; ;;; window=CreateWindow("Directory Browser",0,0,800,600,0,1) ;;; ;;; CreateDirectoryView(window,"C:",50,50,650,450,True) ;;; ;;; While Not id=$803 ;;; ;;; id=WaitEvent() ;;; ;;; Wend ;;; ;;; End ;;; ;;; ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Below are the two functions to add if you wish to use. Function CreateDirectoryView(window,drive$,startx,starty,width,height,viewfiles) ;Set up the screen. main=CreateTreeView(startx,starty,width,height,window) root1=TreeViewRoot(main) folder=AddTreeViewNode(drive$,root1) ;End AddFolderContents(drive$,file$,folder,viewfiles) End Function ;End of the first function, now for the second. Function AddFolderContents(drive$,file$,folder,viewfiles) dir=ReadDir(drive$+""+file$) While MoreFiles(dir) file2$=NextFile(dir) If file2$ <> "." Then If file2$ <> ".." Then If FileType(drive$+""+file$+""+file2$) = 2 Then folder2=AddTreeViewNode(file2$,folder) drive2$=drive$+""+file$ AddFolderContents(drive2$,file2$,folder2,viewfiles) Else If viewfiles=True Then folder2=AddTreeViewNode(file2$,folder) EndIf EndIf EndIf Wend End Function ;END