Click to See Complete Forum and Search --> : OLE Drag Drop for treeView control


Ali Habib
October 18th, 2001, 03:38 AM
I have a tree view control in my application. I want to drag a node from applications tree view control and drop it in another application. While dragging I want a paticular icon to be displayed against mouse pointer. Could anyone help me in doing this. I have tried DragIcon property but that changes the icon if you drag the control rather than the contents of the control. I also tries the screen.mousepointer and screen.mouseicon properties but could not achieve the desired function. Any help in this regard will be greated appreciated.

Thanks

Ali.

Dan Dzina
November 28th, 2001, 07:25 PM
If you want to change the mouse pointer, you need to respond to the _OLEGiveFeedback event.
In the event handler for the control, first set "DefaultCursors" to false, then you can change the cursor through the Screen object.

Example:
Private Sub UserControl_OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean)
DefaultCursors = False
Screen.MouseIcon = imglstDrag.ListImages.Item(GetDragImgID(m_DragNode.Tag.typeobj)).ExtractIcon
Screen.MousePointer = vbCustom
End Sub


Its kind of obsurce, but Microsoft actually documented it in the documented titled:

Dragging the OLE Drag Source over the OLE Drop Target

In the Visual Basic Concepts section of the MSDN library

Dan Dzina
November 28th, 2001, 07:46 PM
I should have also mentioned that with the tree control, you will be responding to an event like TreeView1_OLEGiveFeedback, not usercontrol (as in the code example). Also, in the _OLECompleteDrag, you will need to set the screen.mousepointer back to vb default.

Ravi Kiran
November 29th, 2001, 02:42 AM
Treeview has a createDragImage property using which you can set an image.. i will check if i can provide you the code..


RK

Ali Habib
November 29th, 2001, 08:48 AM
Thankyou very much for your help.

Regards

Ali.