Drag and drop - How to do - like itunes-software
Drag and drop - How to do - like itunes-software
Is it possible to realize a "Drag&Drop" to a listbox
by marking the list with the item which is dropped in?
Regards
Otto
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
//-------------------------------------
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Otto,
You have to calculate the right height based on the font that you use, but basically is like this:
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 ) ) }
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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
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
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
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Otto,
Just an early prototype. As you see it means a lot of work to get such effect:
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact: