# Treeview Drag and Drop... Move the item

## Recommended Posts

I've come to a roadblock and need a little help. I am trying to write a notecard program. Card titles on the left (Treeview) Content on the right (editbox). I need to be able to move the title up and down the tree rather than simple sort them. I can get the 'drag and drop' icons but cannot figure out how to determine the desitination.. Once I know that I can easily move the array content and redisplay the tree.

My confusion is due to the fact that there are newer tree functions now (UDF) that weren't available when the examples were written.

To run the progam and get results... use the latest beta.. Select "Import" and it will load a fixed tree rather than import a file.

Any help greatly appreciated !!!

testfolder.au3

##### Share on other sites

Well, after your initial thread (why create another?) I happened to experiment on the subject too.

Might wanna take a look at

http://www.autoitscript.com/forum/index.php?showtopic=56411

##### Share on other sites

Siao I'm looking at the code..but it won't run.. getting error:

Running AU3Check (1.54.9.0) from:C:\Program Files\AutoIt3\beta

C:\Program Files\AutoIt3\beta\Include\GuiTreeView.au3(468,68) : WARNING: $DEFAULT_GUI_FONT: possibly used before declaration. _WinAPI_SetFont ($hTree, _WinAPI_GetStockObject ($DEFAULT_GUI_FONT) C:\Program Files\AutoIt3\beta\Examples\tt.au3(226,99) : WARNING:$SRCCOPY: possibly used before declaration.

Global Const $SRCCOPY = 0xCC0020 "be smart, drink your wine" #### Share this post ##### Link to post ##### Share on other sites OUTSTANDING! I may get this thing written yet ! #### Share this post ##### Link to post ##### Share on other sites Siao: I was close !! But no cigar yet. I'm having an issue after an item is moved in the tree. The original tree load gives direct ctrl-ids to each item in the tree view. When I hi-lite one, I can trap the ctrl number and place text in the edit box on the right. When the tree is recalculated it's done in "index" mode, I think. So, all the contol-id's are no longer used (I get dup ctrl ids when the moved item is hilited). I could use a little insight into how the treemove is being done. Yes Ive read the code and assoc doc but it's above my level (so far). Any pointers .. what I want to be able to do is .. capturer the treeview list (I initially capture it in an array) and the associated text (in the second col of the array) so they need to be re-associated or kept in sync after the treemove. I can load the current source if you need to see what I am doing in detail #### Share this post ##### Link to post ##### Share on other sites 1) Work with item handles instead of controlIDs. None of the GuiCtrl... funcs will work obviously, since the items are not recreated with GUICtrlCreateTreeViewItem(). Use _GUICtrlTreeView_GetText() to get the text. 2) To trap selection change, add$TVN_SELCHANGED and $TVN_SELCHANGEDW case to WM_NOTIFY function. See the example, which I updated somewhat. Also might wanna see this list of treeview notifications if you need to trap some other events. Edited by Siao "be smart, drink your wine" #### Share this post ##### Link to post ##### Share on other sites Siao, Thanks I will play with it during my breaks at work ! by the way.. when I move an item in the tree - it's stops after the srop..in the WM_notify func. No error.. just stops #### Share this post ##### Link to post ##### Share on other sites Eh, frankly I don't know why it crashes. That _GUICtrlTreeView_GetText inside$TVN_SELCHANGEDW clashes with something else.

It runs without crash with v3.2.9.4 though.

##### Share on other sites

I commented it out for now and it's running . I should be able to play getting it meshed into mine !

I can't thank you enough ! Othe than perhaps posted my end results with appropriate acknowledgments

## Create an account

Register a new account