Hi,
I 'hacked'

Dragging gadgets is easy enough. Dragging the contents of gadgets is easy. However, dragging the text content of a gadget in such a way that a copy of the content moves with the cursor, is perhaps not so easy - unless I've missed something!
The following example uses a dirty trick and shows one way of dragging and dropping the contents of just about any gadget in a visual manner; that is you can see what is being dragged as you move the cursor around. The example shows a text gadget, a string gadget and a ListView gadget.
Code: Select all
;Drag and drop the contents of gadgets.
;This can be changed to accommodate just about any kind of gadget.
;It uses a dirty trick with a hidden ListIcon gadget.
;By Stephen Rodriguez.
;Purebasic 4 beta 11. Tested on Win XP only.
#text1=1
#text2=2
#text3=3
If OpenWindow(0, 0, 0, 600, 300,"Drag and drop between gadgets.", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
TextGadget(#text1,25,20,180,20, "Drag between any of these gadgets")
StringGadget(#text2,25,50,180,20, "Drop on to any of these gadgets")
ListViewGadget(#text3, 25, 90, 250, 120)
For a = 0 To 3
AddGadgetItem (#text3, -1, "Item " + Str(a)) ; define listview content
Next
Repeat
ev=WaitWindowEvent()
Select ev
Case #WM_LBUTTONDOWN
Debug 1
dragfrom=GetDlgCtrlID_(ChildWindowFromPoint_(WindowID(0), WindowMouseY(0) << 32 + WindowMouseX(0)))
If dragfrom>=#text1 And dragfrom<=#text3
;User clicked a text gadget.
;Create a temporary ListIcon gadget so that windows will do all the hard work in displaying the
;drag image!
templisticon=ListIconGadget(#PB_Any, 0, 0, 0, 190, "", 190)
AddGadgetItem(templisticon, -1, "Gadget1 - Item"+Str(i))
SetGadgetItemText(templisticon,0,GetGadgetText(dragfrom),0)
DragImageList = SendMessage_(GadgetID(templisticon), #LVM_CREATEDRAGIMAGE, 0, @UpperLeft.POINT)
If DragImageList
If ImageList_BeginDrag_(DragImageList , 0, 0, 0)
ImageList_DragShowNolock_(#True)
SetCapture_(WindowID(0))
ShowCursor_(#False)
IsDraging = #True
Else
ImageList_Destroy_(DragImageList)
FreeGadget(templisticon)
EndIf
Else
FreeGadget(templisticon)
EndIf
EndIf
Case #WM_MOUSEMOVE
GetCursorPos_(pt.point)
ImageList_DragMove_(pt\x,pt\y)
;The following 2 lines will need uncommenting if some more detailed processing is to occur here.
; ImageList_DragShowNolock_(#False)
; ImageList_DragShowNolock_(#True)
Case #WM_LBUTTONUP
If IsDraging
ReleaseCapture_()
ImageList_EndDrag_()
ImageList_Destroy_(DragImageList)
ShowCursor_(#True)
FreeGadget(templisticon)
IsDraging = #False
;Check to see if the text was dropped onto another text gadget.
dragto=GetDlgCtrlID_(ChildWindowFromPoint_(WindowID(0), WindowMouseY(0) << 32 + WindowMouseX(0)))
Select dragto
Case #text1, #text2
;Drop the text onto the targetted gadget.
SetGadgetText(dragto, GetGadgetText(dragfrom))
Case #text3 ;ListView gadget.
AddGadgetItem (dragto, -1, GetGadgetText(dragfrom))
EndSelect
EndIf
EndSelect
Until ev = #PB_Event_CloseWindow
EndIf
End