I made this sample test
on oLbx must be allways 4 records and 5 columns
on olbx2 the items can be erased ( but not added to olbx)
With the mouse run perfectly
the button aBtnDropBrw[1] "Drop in"" run
the button aBtnDropBrw[2] "Drop out"" run bad because erase allways the first record and not that on the position
and not I understood How resolve the problem
the test code
- Code: Select all Expand view
#include "FiveWin.ch"
#include "xbrowse.ch"
function Main()
local oDlg, oCursor, oLbx, oLbx2,oFont
local cItem:=""
local aData := Array( 4, 5 )
local i,j
local aBtnDropBrw:=array(2)
//Array Demo Data
for i := 1 to 4
aData[ i ][ 1 ] := 'Prod-' + Chr(64+i)
for j := 2 to 5
aData[ i ][ j ] := Round( hb_Random( 100, 999 ), 2 )
next j
next i
DEFINE CURSOR oCursor hand
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 900,570 PIXEL;
TRUEPIXEL RESIZABLE FONT oFont
// First Listbox
@ 55, 40 XBROWSE oLbx OF oDlg COLUMNS 1,2,3,4,5 ;
ARRAY aData SIZE 350, 200 PIXEL
// 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 )}
// second Listbox
@ 55,oLbx:nwidth+290 XBROWSE oLbx2 ;
OF oDlg COLUMNS 1,2,3,4,5 ARRAY {} ;
size 350,200 pixel
// Set a DropOver action for the ListBox2
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 )}
oLbx:CreateFromCode()
oLbx2:CreateFromCode()
// Set a Drop action for the buttons
@ 95, oLbx:nwidth+90 Button aBtnDropBrw[1] PROMPT "Drop in" OF oDlg;
SIZE 90, 30 PIXEL ;
ACTION (uDropInfo:=SetDropInfo( oLbx:nArrayAt ),;
AAdd( oLbx2:aArrayData, oLbx:aArrayData[oLbx:nArrayAt ] ), ;
oLbx:Refresh(.t.), oLbx2:Refresh(.t.) )
@ 145, oLbx:nwidth+90 Button aBtnDropBrw[2] PROMPT "Drop Out" OF oDlg;
SIZE 90, 30 PIXEL ;
ACTION (uDropInfo:=SetDropInfo( oLbx2:nArrayAt ),;
ADel( oLbx2:aArrayData, uDropInfo, .t. ), ;
oLbx:Refresh(.t.), oLbx2:Refresh(.t.) )
oDlg:bResized := <||
local oRect := oDlg:GetCliRect()
local x := Int( oRect:nWidth / 2 )
oLbx:nWidth := x - 80
oLbx2:nLeft := x + 130
aBtnDropBrw[1]:nTop := oLbx:nTop + 50
aBtnDropBrw[1]:nLeft := oLbx:nWidth + 90
aBtnDropBrw[2]:nTop := oLbx:nTop + 100
aBtnDropBrw[2]:nLeft := oLbx:nWidth + 90
return nil
>
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
If I wrote
@ 145, oLbx:nwidth+90 Button aBtnDropBrw[2] PROMPT "Drop Out" OF oDlg;
SIZE 90, 30 PIXEL ;
ACTION (uDropInfo:=SetDropInfo( oLbx2:nArrayAt ),;
ADel( oLbx2:aArrayData, oLbx2:nArrayAt, .t. ), ;
oLbx:Refresh(.t.), oLbx2:Refresh(.t.) )
It run ok but I not understood what need uDropInfo
then when I take the item fron oLbx to move to oLbx2 it take allways the first and not that where is the cursor
then if I click on a item and press the button then run