User renaming treeview node

BlitzMax Forums/MaxGUI Module/User renaming treeview node

JoshK(Posted 2008) [#1]
Is the manual renaming of a tree node with keyboard input something that Windows actually supports? It would be very useful to allow users to rename nodes without using a popup box or something.


klepto2(Posted 2008) [#2]
yes, its possible.

You have to hack a bit in the win32maxguiex and the users.bmx but its easy to achive.

First add this to the pub.win32.user32.bmx :

Function GetWindowTextA( hwnd)
Function GetWindowTextW( hwnd)


Then modifiy the win32maxguiex.bmx:

Search the TWindowsTreeView Type and add the following field:

Field _edithwnd:Int


then edit the create function and change the wstyle variable to this:

wstyle=WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS|TVS_NOTOOLTIPS|WS_CLIPSIBLINGS|TVS_EDITLABELS


last change : search the OnNotify Method of TWindowsTreeView and add the following in the Select block:

Case TVN_BEGINLABELEDITW
				_edithwnd = SendMessageW(_hwnd,TVM_GETEDITCONTROL,0,0)
			Case TVN_ENDLABELEDITW
				Local buffer:Short[260]
				GetWindowTextW(_edithwnd , buffer , 256) 
				_selected.setText(String.FromShorts(buffer,256))


Rebuild the pub.win32 and maxgui.win32maxguiex modules.
Just start the treeview exsample and select a node. After a second click you're now able to edit the node.

I hope this helps you:)


JoshK(Posted 2008) [#3]
That seems like a big part of it, but the application still needs to be able to turn label editing on:
http://msdn.microsoft.com/en-us/library/bb760017%28VS.85%29.aspx#tv_label_editing


JoshK(Posted 2008) [#4]
In your sample application, if you rename the tree node with the "left-click twice" method, a crash ensues:



klepto2(Posted 2008) [#5]
hmm, it works without crahes here, maybe you can try to avoid crashes by changing this line

_selected.setText(String.FromShorts(buffer,256))


to

if _selected then _selected.setText(String.FromShorts(buffer,256))