Unable to AddTreeViewNode
BlitzMax Forums/MaxGUI Module/Unable to AddTreeViewNode
| ||
| Hey Guys! I keep receiving the error "Unhandled Exception:Attempt to access field or method of Null object" when attempting to use the AddTreeViewNode function. Here's the code..
SuperStrict
Import MaxGUI.Drivers
Local MyWindow:TGadget=CreateWindow("TreeView Example", 40,40,400,400)
Global MyTreeView:TGadget=CreateTreeView(5,0,200,360,MyWindow)
Local Folder:Int=ReadDir(BlitzMaxPath())
Local File:String
Repeat
File=NextFile(Folder)
AddTreeViewNode(file,MyTreeView)
Until File=Null
Repeat
WaitEvent()
Select EventID()
Case EVENT_WINDOWCLOSE
End
End Select
Forever
End
|
| ||
You need to create a 'root' for the tree view and add the nodes to that.
SuperStrict
Import MaxGUI.Drivers
Local MyWindow:TGadget = CreateWindow("TreeView Example", 40, 40, 400, 400)
Global MyTreeView:TGadget = CreateTreeView(5, 0, 200, 360, MyWindow)
Local Root:TGadget = TreeViewRoot(MyTreeView) '<-- ********************
Local Folder:Int = ReadDir(BlitzMaxPath())
Local File:String = ""
Repeat
File = NextFile(Folder)
If File Then AddTreeViewNode(File, Root) '<-- ********************
Until File = Null
Repeat
WaitEvent()
Select EventID()
Case EVENT_WINDOWCLOSE
End
End Select
Forever
End
|
| ||
| Awesome! I guess the tutorial in the tutorial section is a little out dated |