xBrowse Drag & Drop

Post Reply
User avatar
Bayron
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

xBrowse Drag & Drop

Post 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

//----------------------------------------------------------------------------//
=====>

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
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: xBrowse Drag & Drop

Post 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

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

G. N. Rao.
Hyderabad, India
User avatar
fafi
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: xBrowse Drag & Drop

Post by fafi »

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

Thanks
Best Regards
Fafi
User avatar
Bayron
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: xBrowse Drag & Drop

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

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

Post 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

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

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

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

Post 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

//----------------------------------------------------------------------------//
=====>

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