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

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

Postby Otto » Thu Sep 20, 2007 5:46 pm

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

//-------------------------------------
User avatar
Otto
 
Posts: 6327
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Fri Sep 21, 2007 8:00 am

Otto,

You have to calculate the right height based on the font that you use, but basically is like this:
Code: Select all  Expand view
oLbx:bDropOver = { | uDropInfo, nRow, nCol | oLbx:Select( Int( nRow / 20 ) ) }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Fri Sep 21, 2007 1:15 pm

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
User avatar
Otto
 
Posts: 6327
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Fri Sep 21, 2007 3:53 pm

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Fri Sep 21, 2007 7:07 pm

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
User avatar
Otto
 
Posts: 6327
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Sat Sep 22, 2007 6:53 am

Otto,

Just an early prototype. As you see it means a lot of work to get such effect:
Code: Select all  Expand view
#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   
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Sat Sep 22, 2007 6:11 pm

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
User avatar
Otto
 
Posts: 6327
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Sat Sep 22, 2007 6:14 pm

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Sat Sep 22, 2007 7:24 pm

Hello Antonio,
Thank you.
I didn't know that you offer such a service.
I send you an email.
Regards
Otto
User avatar
Otto
 
Posts: 6327
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 86 guests

cron