Page 1 of 1
xBrowse Drag & Drop
Posted: Sat Sep 17, 2011 3:26 am
by Bayron
How can I adapt \samples\testdrp6.prg to be used with xBrowse, If someone has an example with a DBF, will be better...
Code: Select all
// FiveWin - own Drag&Drop new features !!!
// Drag item from one listbox to another listbox
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
local oWnd, oCursor, oLbx, oLbx2
local cItem:=""
DEFINE CURSOR oCursor hand
DEFINE WINDOW oWnd TITLE "FiveWin's own Drag & Drop features!!!"
@ 6, 3 LISTBOX oLbx VAR cItem ;
ITEMS { "Item 1","Item 2","Item 3","Item 4" } SIZE 400, 400
// Set a DropOver action for the ListBox
oLbx:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
oLbx:Add( uDropInfo ), oLbx2:del(), MsgBeep() }
oLbx:oDragCursor = oCursor // Select a Drag cursor
oLbx:bDragBegin = { | nRow, nCol, nKeyFlags | ;
SetDropInfo( oLbx:getSelText() ),; // Save drop info !!!
oWnd:SetMsg( "Dragging..." ) }
@ 6, 30 LISTBOX oLbx2 var cItem;
ITEMS {} size 400,400
// Set a DropOver action for the ListBox
oLbx2:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
oLbx2:Add( uDropInfo ), oLbx:del(), MsgBeep() }
oLbx2:oDragCursor = oCursor // Select a Drag cursor
oLbx2:bDragBegin = { | nRow, nCol, nKeyFlags | ;
SetDropInfo( oLbx2:getSelText() ),; // Save drop info !!!
oWnd:SetMsg( "Dragging..." ) }
SET MESSAGE OF oWnd ;
TO "FiveWin - own DragDrop interface !!!" CENTER
ACTIVATE WINDOW oWnd MAXIMIZED
return nil
//----------------------------------------------------------------------------//
Re: xBrowse Drag & Drop
Posted: Sat Sep 17, 2011 7:32 am
by nageswaragunupudi
Code: Select all
// FiveWin - own Drag&Drop new features !!!
// Drag item from one listbox to another listbox
#include "FiveWin.ch"
#include "xbrowse.ch"
//----------------------------------------------------------------------------//
function Main()
local oWnd, oCursor, oLbx, oLbx2
local cItem:=""
DEFINE CURSOR oCursor hand
DEFINE WINDOW oWnd TITLE "FiveWin's own Drag & Drop features!!!"
@ 6, 3 XBROWSE oLbx OF oWnd COLUMNS 1 ;
ARRAY { "Item 1","Item 2","Item 3","Item 4" } SIZE 200, 200
// Set a DropOver action for the ListBox
oLbx:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
AAdd( oLbx:aArrayData, oLbx2:aArrayData[ uDropInfo ] ), ;
ADel( oLbx2:aArrayData, uDropInfo, .t. ), ;
oLbx:Refresh(.t.), oLbx2:Refresh(.t.) }
oLbx:oDragCursor = oCursor // Select a Drag cursor
oLbx:bDragBegin = { | nRow, nCol, nKeyFlags | ;
SetDropInfo( oLbx:nArrayAt ),; // Save drop info !!!
oWnd:SetMsg( "Dragging..." ) }
@ 6, 30 XBROWSE oLbx2 OF oWnd COLUMNS 1 ARRAY {} size 200,200
oLbx2:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
AAdd( oLbx2:aArrayData, oLbx:aArrayData[ uDropInfo ] ), ;
ADel( oLbx:aArrayData, uDropInfo, .t. ), ;
oLbx:Refresh(.t.), oLbx2:Refresh(.t.) }
oLbx2:oDragCursor = oCursor // Select a Drag cursor
oLbx2:bDragBegin = { | nRow, nCol, nKeyFlags | ;
SetDropInfo( oLbx2:nArrayAt ),; // Save drop info !!!
oWnd:SetMsg( "Dragging..." ) }
oLbx:CreateFromCode()
oLbx2:CreateFromCode()
// Set a DropOver action for the ListBox
SET MESSAGE OF oWnd ;
TO "FiveWin - own DragDrop interface !!!" CENTER
ACTIVATE WINDOW oWnd MAXIMIZED
return nil
//----------------------------------------------------------------------------//
Re: xBrowse Drag & Drop
Posted: Sat Sep 17, 2011 10:36 am
by fafi
to Mr. nageswaragunupudi..
How to work with database files
Can I get the sample..
Thanks
Best Regards
Fafi
Re: xBrowse Drag & Drop
Posted: Sat Sep 17, 2011 1:26 pm
by Bayron
Thanks Mr. Rao, this is a nice example... I think it will of a lot of help if it's placed in the \Samples folder...
I have one question:
If I Click, Hold, Drag and Drop one array item in the same xBrowse from where it was taken, and the other xBrowse has Items, the selected Row in the other xBrowse is moved this xBrowse... and If I do the same and there are no more array items in the other xBrowse, I get a array access error....
Same thing was happening in the \samples\testdrp6.prg
How can I prevent this from happening???
Re: xBrowse Drag & Drop
Posted: Sat Sep 17, 2011 2:31 pm
by Bayron
Fixed It with a conditional Drop:
If( !Empty( uDropInfo ) .and. LEN(aLbx2) <> 0
Code: Select all
// FiveWin - own Drag&Drop new features !!!
// Drag item from one listbox to another listbox
#include "FiveWin.ch"
#include "xbrowse.ch"
//----------------------------------------------------------------------------//
function Main()
local oWnd, oCursor, oLbx, oLbx2
local cItem:=""
DEFINE CURSOR oCursor hand
DEFINE WINDOW oWnd TITLE "FiveWin's own Drag & Drop features!!!"
aLbx := { "Item 1","Item 2","Item 3","Item 4" }
@ 6, 3 XBROWSE oLbx OF oWnd COLUMNS 1 ;
ARRAY aLbx SIZE 300, 300
WITH OBJECT oLbx
:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
If( !Empty( uDropInfo ) .and. LEN(aLbx2) <> 0 , ( AAdd( oLbx:aArrayData, oLbx2:aArrayData[ uDropInfo ] ) , ;
ADel( oLbx2:aArrayData, uDropInfo, .t. ), ;
oLbx:Refresh(.t.), oLbx2:Refresh(.t.) ) , ) }
:oDragCursor = oCursor // Select a Drag cursor
:bDragBegin = { | nRow, nCol, nKeyFlags | ;
SetDropInfo( oLbx:nArrayAt ),; // Save drop info !!!
oWnd:SetMsg( "Dragging..." ) }
END
aLbx2 := {}
@ 6, 45 XBROWSE oLbx2 OF oWnd COLUMNS 1 ARRAY aLbx2 size 300,300
WITH OBJECT oLbx2
:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
If( !Empty( uDropInfo ) .and. LEN(aLbx) <> 0, ( AAdd( oLbx2:aArrayData, oLbx:aArrayData[ uDropInfo ] ), ;
ADel( oLbx:aArrayData, uDropInfo, .t. ), ;
oLbx:Refresh(.t.), oLbx2:Refresh(.t.) ) , ) }
:oDragCursor = oCursor // Select a Drag cursor
:bDragBegin = { | nRow, nCol, nKeyFlags | ;
SetDropInfo( oLbx2:nArrayAt ),; // Save drop info !!!
oWnd:SetMsg( "Dragging..." ) }
END
oLbx:CreateFromCode()
oLbx2:CreateFromCode()
// Set a DropOver action for the ListBox
SET MESSAGE OF oWnd ;
TO "FiveWin - own DragDrop interface !!!" CENTER
ACTIVATE WINDOW oWnd MAXIMIZED
return nil
//----------------------------------------------------------------------------//
Re: xBrowse Drag & Drop
Posted: Sat Sep 17, 2011 2:39 pm
by Bayron
Too Soon...
How can I detect from which browse es the Record comming from???
I want to prevent the Record of being Dropped in the xBrowse from which it was taken...
Re: xBrowse Drag & Drop
Posted: Sat Sep 17, 2011 2:58 pm
by Bayron
It may not be the pretiest and right way to doit, but I got it working like this:
nXBrow := x
Code: Select all
// FiveWin - own Drag&Drop new features !!!
// Drag item from one listbox to another listbox
#include "FiveWin.ch"
#include "xbrowse.ch"
//----------------------------------------------------------------------------//
function Main()
local oWnd, oCursor, oLbx, oLbx2
local cItem:=""
local nxBrow := 0
local aLbx := { "Item 1","Item 2","Item 3","Item 4" }
local aLbx2 := { }
DEFINE CURSOR oCursor hand
DEFINE WINDOW oWnd TITLE "FiveWin's own Drag & Drop features!!!"
@ 6, 3 XBROWSE oLbx OF oWnd COLUMNS 1 ;
ARRAY aLbx SIZE 300, 300
WITH OBJECT oLbx
:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
If( !Empty( uDropInfo ) .and. LEN(aLbx2) <> 0 .and. nxBrow <> 1 , ( AAdd( oLbx:aArrayData, oLbx2:aArrayData[ uDropInfo ] ) , ;
ADel( oLbx2:aArrayData, uDropInfo, .t. ), ;
oLbx:Refresh(.t.), oLbx2:Refresh(.t.) ) , ) }
:oDragCursor = oCursor // Select a Drag cursor
:bDragBegin = { | nRow, nCol, nKeyFlags | ;
nxBrow := 1 , ;
SetDropInfo( oLbx:nArrayAt ),; // Save drop info !!!
oWnd:SetMsg( "Dragging..." ) }
END
@ 6, 45 XBROWSE oLbx2 OF oWnd COLUMNS 1 ARRAY aLbx2 size 300,300
WITH OBJECT oLbx2
:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
If( !Empty( uDropInfo ) .and. LEN(aLbx) <> 0 .and. nxBrow <> 2 , ( AAdd( oLbx2:aArrayData, oLbx:aArrayData[ uDropInfo ] ), ;
ADel( oLbx:aArrayData, uDropInfo, .t. ), ;
oLbx:Refresh(.t.), oLbx2:Refresh(.t.) ) , ) }
:oDragCursor = oCursor // Select a Drag cursor
:bDragBegin = { | nRow, nCol, nKeyFlags | ;
nxBrow := 2 , ;
SetDropInfo( oLbx2:nArrayAt ),; // Save drop info !!!
oWnd:SetMsg( "Dragging..." ) }
END
oLbx:CreateFromCode()
oLbx2:CreateFromCode()
// Set a DropOver action for the ListBox
SET MESSAGE OF oWnd ;
TO "FiveWin - own DragDrop interface !!!" CENTER
ACTIVATE WINDOW oWnd MAXIMIZED
return nil
//----------------------------------------------------------------------------//