Extended TreeView
BlitzPlus Forums/BlitzPlus Programming/Extended TreeView
| ||
Hi! I'm working on an application in B+, and I am using a treeview. http://phoenixoft.com/Designer.rar It would be great to modify the treeview a little, to make it support two extra things: Name modification, so that you can change the name of a treeview node by clicking on it twice. And drag & drop, so that you can move the nodes however you want. I know this can be done with SetWindowLong, SendMessage etc. I have tried to make it work, but without success. Here's my code: ; Treeview constants 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 ; Create the gadgets window = CreateWindow( "Extended TreeView Test", 200, 200, 220, 140, Desktop( ), 1 ) tree = CreateTreeView( 10, 10, 200, 100, window ) node = AddTreeViewNode( "TEXT", TreeViewRoot( tree ) ) ; Modify the treeview ; api_SetWindowLong( QueryObject( tree, 1 ), ?, ? ) ; Loop While WaitEvent( )<>$803 Wend I think that the standard blitz treeview has the flag TVS_DISABLEDRAGDROP, so I have to remove that, and I have to add TVS_EDITLABELS. There are people here who can solve this problem, please help me out. |
| ||
I managed to get checkboxes and underlined nodes, but still no luck on the other things... |
| ||
Yes! I fixed the TVS_EDITLABELS constant, but I still have a problem, when I've entered the text, it doesn't change the text of the node...; TVS Constants 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 ; Style, do NOT modify! Const GWL_STYLE = -16 ; Create the gadgets window = CreateWindow( "Extended TreeView Test", 200, 200, 220, 140, Desktop( ), 1 ) tree = CreateTreeView( 10, 10, 200, 90, window ) node = AddTreeViewNode( "TEXT", TreeViewRoot( tree ) ) node2 = AddTreeViewNode( "TEXT2", node ) node3 = AddTreeViewNode( "TEXT3", TreeViewRoot( tree ) ) node4 = AddTreeViewNode( "TEXT4", TreeViewRoot( tree ) ) ; Modify the treeview Treehwnd = QueryObject( tree, 1 ) style = api_GetWindowLong( Treehwnd, GWL_STYLE ) api_SetWindowLong( Treehwnd, GWL_STYLE, style + TVS_EDITLABELS ) ; Loop While WaitEvent( )<>$803 Wend |
| ||
hi the problem with trying this using blitz+ is when treeview nodes are edited there event comes through WM_NOTIFY, as TVN_ENDLABELEDIT now lParam will give a pointer TV_DISPINFO and from this structure you need to get a pointer to TV_ITEM structure only then will you be-able to get the text the user has typed in. treeview checkbox might be possable you would need to setup a function to get the contents of the treeview node, then check the state mask. kev |
| ||
So, there is no way to get the text the user typed in? |
| ||
hi yes using a .dll if you code using c, then you could setup a hook using SetWindowsHookEx() using WH_CALLWNDPROCRET or WH_CALLWNDPROC hook then you could process the messages before or after blitz+ gets them. somthing this this HHOOK HookRET = SetWindowsHookEx(WH_CALLWNDPROCRET,GLOBAL_HOOKED_MESSAGE_WINPROC_RET,0,GetCurrentThreadId()); where GLOBAL_HOOKED_MESSAGE_WINPROC_RET is a callback, ie. LRESULT CALLBACK GLOBAL_HOOKED_MESSAGE_WINPROC_RET(int code,WPARAM wParam,LPARAM lParam){ if(code<<HC_ACTION){ return CallNextHookEx(HookRET,code,wParam,lParam); }else{ CWPRETSTRUCT *msg = (CWPRETSTRUCT*)lParam; // process you hooked events here } } kev |
| ||
Windows programming has never been my strong side, I'll just skip the whole edit label part... |