xBrowse Drag & Drop

xBrowse Drag & Drop

Postby Bayron » Sat Sep 17, 2011 3: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: Select all  Expand view
// 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
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: xBrowse Drag & Drop

Postby nageswaragunupudi » Sat Sep 17, 2011 7:32 am

Code: Select all  Expand view
// 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
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse Drag & Drop

Postby fafi » 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
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: xBrowse Drag & Drop

Postby Bayron » Sat Sep 17, 2011 1: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
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: xBrowse Drag & Drop

Postby Bayron » Sat Sep 17, 2011 2:31 pm

Fixed It with a conditional Drop:
If( !Empty( uDropInfo ) .and. LEN(aLbx2) <> 0

Code: Select all  Expand view
// 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

//----------------------------------------------------------------------------//
Last edited by Bayron on Sat Sep 17, 2011 2:40 pm, edited 1 time in total.
=====>

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

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: xBrowse Drag & Drop

Postby Bayron » Sat Sep 17, 2011 2: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
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: xBrowse Drag & Drop

Postby Bayron » Sat Sep 17, 2011 2:58 pm

It may not be the pretiest and right way to doit, but I got it working like this:

nXBrow := x

Code: Select all  Expand view
// 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
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 101 guests