Page 1 of 1

Drag and drop - How to do - like itunes-software

Posted: Thu Sep 20, 2007 5:46 pm
by Otto
Image

Is it possible to realize a "Drag&Drop" to a listbox
by marking the list with the item which is dropped in?

Regards
Otto

Image

Is it possible to realize a “Drag&Drop” from a browser to a listbox by marking the list the item is dropped in? I have included a graphical example from my itunes-software where songs can be selected and put from a common pool into a specific playlist. The selected playlist remains marked until the action is finished.
img]http://www.atzwanger.com/fw/Clip2.jpg[/img]



#include "FiveWin.ch"
//----------------------------------------------------------------------------//

function Main()
local oWnd, oCursor, oBtn, oLbx, cItem

DEFINE CURSOR oCursor RESOURCE "book"
DEFINE WINDOW oWnd TITLE "FiveWin own Drag-Drop features!!!"

@ 3, 3 BUTTON oBtn PROMPT "DragMe/DropMe at the Listbox" SIZE 210, 25

oBtn:oDragCursor = oCursor
oBtn:bDragBegin = { | nRow, nCol, nKeyFlags | SetDropInfo( Time() ) }

@ 6, 3 LISTBOX oLbx VAR cItem ;
ITEMS { "I am a listbox!","Apples", "Oranges", "Lemons", "Limes" } SIZE 200, 200

// Set a DropOver action for the ListBox
oLbx:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
msginfo(uDropInfo),msginfo(str(nRow)+" " + str(nCol) + " " + str(nKeyFlags)) }

ACTIVATE WINDOW oWnd MAXIMIZED

return nil

//-------------------------------------

Posted: Fri Sep 21, 2007 8:00 am
by Antonio Linares
Otto,

You have to calculate the right height based on the font that you use, but basically is like this:

Code: Select all

oLbx:bDropOver = { | uDropInfo, nRow, nCol | oLbx:Select( Int( nRow / 20 ) ) } 

Posted: Fri Sep 21, 2007 1:15 pm
by Otto
Hello Antonio,
thank you.
But this only works if you drop the item. You don't see before you drop what exactly you have selected.
Also scroll doesn’t work.
Regards
Otto

Posted: Fri Sep 21, 2007 3:53 pm
by Antonio Linares
Otto,

In Class TXBrwColumn Method MouseMove() you have an example about how to show an item and move it. Basically you create a child window:

DEFINE WINDOW ::oDragWnd OF ::oBrw STYLE WS_CHILD
::oDragWnd:bPainted := {| hDC | ::PaintHeader( 0, 0, ::oBrw:nHeaderHeight, .t., hDC ),;
WndRaised( ::oDragWnd:hWnd, hDC ) }
::oDragWnd:Move(nRow, nCol, ::nWidth, ::oBrw:nHeaderHeight)
ACTIVATE WINDOW ::oDragWnd

Posted: Fri Sep 21, 2007 7:07 pm
by Otto
Hello Antonio,
Thank you.
If I understand the code well this is the drag event part.
What I would need is the target selection part, too.

Maybe you can provide a working example. This functionality is a must. The young generation is working that way. All the things are dragged to “MY …” the way iTune does.

Regards
Otto

Posted: Sat Sep 22, 2007 6:53 am
by Antonio Linares
Otto,

Just an early prototype. As you see it means a lot of work to get such effect:

Code: Select all

#include "FiveWin.ch"

static oWnd, oChild

function Main()

   DEFINE WINDOW oWnd

   // oWnd:bMMoved = { | nRow, nCol | MoveChild( nRow, nCol ) }

   ACTIVATE WINDOW oWnd ;
      ON CLICK CreateChild( nRow, nCol, oWnd )

return nil

function CreateChild( nRow, nCol, oWnd )

   if oChild == nil
      DEFINE WINDOW oChild OF oWnd STYLE WS_CHILD COLOR "W/B"
      oChild:SetSize( 100, 22 )
      oChild:Show()
      oChild:bPainted = { | hDC | oChild:Say( 0.3, 0.3, "Hello world!" ) }
      oChild:bMMoved = { | nRow, nCol | MoveInParent( nRow, nCol ) }
   endif   

   oChild:Move( nRow, nCol,,, .T. )
   
return nil   

function MoveChild( nRow, nCol )

   if oChild != nil
      oChild:Move( nRow, nCol,,, .T. )
   endif   

return nil

function MoveInParent( nRow, nCol )

   local aPos := { nRow, nCol }
   
   ClientToScreen( oChild:hWnd, aPos )
   ScreenToClient( oWnd:hWnd, aPos )
   
   oChild:Move( aPos[ 1 ] - 10, aPos[ 2 ] - 20,,, .T. )
   
return nil   

Posted: Sat Sep 22, 2007 6:11 pm
by Otto
Hello Antonio,

I had a look – this is what I need.
Do you think you get it going and if yes what would be the timeframe.
Thanks in advance
Otto

Posted: Sat Sep 22, 2007 6:14 pm
by Antonio Linares
Otto,

Why don't you consider to do it yourself ? :-)
I am sure that you have the technical skills to complete it.

If you want me to do it, send me an email and we will talk about the timeframe and price

Posted: Sat Sep 22, 2007 7:24 pm
by Otto
Hello Antonio,
Thank you.
I didn't know that you offer such a service.
I send you an email.
Regards
Otto