[MaxGui] Delete TreeviewItems

BlitzMax Forums/BlitzMax Beginners Area/[MaxGui] Delete TreeviewItems

Kernle 32DLL_2(Posted 2006) [#1]
hi
At the moment i'm looking for a function which can delete items of a treeviewnode. Can somebody help me?thx


assari(Posted 2006) [#2]
Use FreeTreeViewNode. See example below. Doubleclick to delete

SuperStrict

Local MyWindow:TGadget=CreateWindow("TreeView Example", 40,40,400,400)
Global MyTreeView:TGadget=CreateTreeView(5,0,200,330,MyWindow)

EnumFiles(BlitzMaxPath(),MyTreeView)

Repeat
  WaitEvent()
  Select EventID()
  Case EVENT_WINDOWCLOSE
     End

  Case EVENT_GADGETACTION
        Local Node:TGadget = SelectedTreeViewNode(MyTreeView)
	FreeTreeViewNode(Node)

  End Select
Forever
End

Function EnumFiles:Int(Dir:String, Parent:TGadget)

  Local Folder:Int=ReadDir(Dir)
  Local File:String
  Local FullPath:String

  Repeat
      File=NextFile(Folder)
      If File=".." Or File="." Or File=Null Then
          'Do Nothing
      Else
          fullPath = RealPath(Dir+"/"+file)
          If FileType(FullPath)=FILETYPE_DIR Then
            Local handle:TGadget=AddTreeViewNode(file,Parent,1)
            handle.context=FullPath
          Else
              AddTreeViewNode(file,Parent,0)
          EndIf
      EndIf
  Until File=Null

End Function