FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse Drag & Drop
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
xBrowse Drag & Drop
Posted: Sat Sep 17, 2011 03:26 AM
How can I adapt \samples\testdrp6.prg to be used with xBrowse, If someone has an example with a DBF, will be better...

Code (fw): Select all Collapse
// 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

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

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse Drag & Drop
Posted: Sat Sep 17, 2011 07:32 AM
Code (fw): Select all Collapse
// 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

//----------------------------------------------------------------------------//
Regards



G. N. Rao.

Hyderabad, India
Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
Re: xBrowse Drag & Drop
Posted: Sat Sep 17, 2011 10:36 AM

to Mr. nageswaragunupudi..
How to work with database files
Can I get the sample..

Thanks
Best Regards
Fafi

Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: xBrowse Drag & Drop
Posted: Sat Sep 17, 2011 01:26 PM

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???

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: xBrowse Drag & Drop
Posted: Sat Sep 17, 2011 02:31 PM
Fixed It with a conditional Drop:
If( !Empty( uDropInfo ) .and. LEN(aLbx2) <> 0

Code (fw): Select all Collapse
// 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

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

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: xBrowse Drag &amp; Drop
Posted: Sat Sep 17, 2011 02:39 PM

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...

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: xBrowse Drag &amp; Drop
Posted: Sat Sep 17, 2011 02:58 PM
It may not be the pretiest and right way to doit, but I got it working like this:

nXBrow := x

Code (fw): Select all Collapse
// 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

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

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Continue the discussion