I want to drag an item from a treeview to a canvas

BlitzMax Forums/BlitzMax Programming/I want to drag an item from a treeview to a canvas

JoshK(Posted 2008) [#1]
I want to drag an item from a treeview to a canvas. Is this possible with the windows API? I don't care if it is tricky, but it is possible?


Dreamora(Posted 2008) [#2]
Should be simple:

- handle the single click on the tree and the item. Think the select event is fired in that case. (and action on double click)
- Change cursor icon and remove the item from tree but store its parent if you need to put it in again as it was not dropped on canvas
- handle the mousebutton up over the canvas -> drop there and


JoshK(Posted 2008) [#3]
I don't actually need to remove the item, but I want some kind of transparent icon to appear next to the mouse cursor, so it is apparent to the user you are dragging something into the canvas.

I would be very surprised if the canvas fired a mouse up event from a button press that originated elsewhere.


Dreamora(Posted 2008) [#4]
icon: Change the mouse cursor to show an icon

mouse up: if you check if the mouse is over the canvas (in the mouse move) and manually set it to active, then yes it will fire one :)


JoshK(Posted 2008) [#5]
Just because a treeviewnode was selected doesn't mean you are holding down the mouse. Does Windows support something like this? I am not interested in home-made solutions that don't work.


plash(Posted 2008) [#6]
http://msdn2.microsoft.com/en-us/library/bb773409(VS.85).aspx

MR offensive.


Dreamora(Posted 2008) [#7]
Windows does support a lot but unless you wrote LeadwerksGUI to do it for you, you won't have it.
Using Windows API and operating on MaxGUI stuff is critical because it can potentially just change and your stuff will be broken.


JoshK(Posted 2008) [#8]
Oh sweet, I didn't realize it was right there. Thanks.

This will be tricky, but it's worthwhile.


JoshK(Posted 2008) [#9]
Well I can detect tree view drag events:
case TVN_BEGINDRAG:
MessageBox(0,"Tree View Drag Event","Tree View Drag Event",MB_OK);

Only problem so far is when I drag a treeview item, BlitzMax automatically selects the last selected node, not the one I am dragging. How can I change this?

Right now I am trying to make Windows select the treeviewnode when a drag operation starts:

From win32treeview.cpp:
	case TVN_BEGINDRAG:
		//MessageBox(0,"Tree View Drag Event","Tree View Drag Event",MB_OK);
		_selected=(Win32TreeViewNode*)nm->itemNew.lParam;		
		SendMessage(_gadget.hwnd(),TVM_SELECTITEM,TVGN_CARET,(int)_selected);
		emit( 690,(int)_selected );
		break;


Judging from the results of the other tree events, it doesn't look like treeview events in maxgui actually return the treeview node gadget they should.