by Randal » Thu Nov 25, 2010 5:16 pm
Pete:
I had a similar situation dragging/dropping between two browses. In this case I'm browsing two arrays. I refer to browse 1 as a "Time" browse and browse 2 as a "Timeless" browse.
Here are the drag/drop definitions for each browse:
oBrw:bDragBegin := { |nRow,nCol,nKeyFlags| ;
SetDropInfo( {oBrw:nColSel, oBrw:nArrayAt, "B1"} ), oWnd:SetMsg("Dragging") }
oBrw:bDropOver := { |uDropInfo, nRow, nCol, nKeyFlags | ;
DragDrop(uDropInfo,nRow,nCol,nKeyFlags,oBrw,oBrw2) }
oBrw2:bDragBegin := { |nRow,nCol,nKeyFlags| ;
SetDropInfo( {oBrw2:nColSel, oBrw2:nArrayAt, "B2"} ), oWnd:SetMsg("Dragging") }
oBrw2:bDropOver := { |uDropInfo, nRow, nCol, nKeyFlags | ;
DragDrop2(uDropInfo,nRow,nCol,nKeyFlags,oBrw,oBrw2) }
As you can see I'm saving a value (B1,B2) so I can later determine which browse they are dropping to.
Here is the drag/drop functions for each browse. I hope this is not too convoluted as I've tried to cut out my code that is not applicable to your question.
STATIC FUNCTION DragDrop(uDropInfo,nRow,nCol,nKeyFlags,oBrw,oBrw2)
LOCAL nColPos
LOCAL x,i
LOCAL nRowFrom, nColFrom
LOCAL nRowTo, nColTo
LOCAL uButtonDown
LOCAL aPoint
// Dragging from time browse and dropping on time browse.
IF uDropInfo[3] == "B1"
// Reposition browse cursor to drop location
oBrw:lButtonDown(nRow, nCol, nKeyFlags)
oBrw:lButtonUp(nRow, nCol, nKeyFlags)
// Get the drop to row and column
nRowTo := oBrw:Cargo
nColTo := oBrw:nColSel
// Dragging from timeless browse & dropping on time browse
ELSE
// Reposition browse cursor to drop location
if nRow > 32000
nRow = - ( 65535 - nRow )
endif
if nCol > 32000
nCol = - ( 65535 - nCol )
endif
aPoint = { nRow, nCol }
aPoint = ClientToScreen( GetFocus(), aPoint )
ScreenToClient( oBrw:hWnd, aPoint )
nRow := aPoint[1]
nCol := aPoint[2]
uButtonDown := oBrw:lButtonDown(nRow, nCol, nKeyFlags)
oBrw:lButtonUp(nRow, nCol, nKeyFlags)
// Unable to set row,col on browse. Must have dropped somewhere outside valid cell
IF uButtonDown = nil
RETURN NIL
ENDIF
// Get the drop to row and column
nRowTo := oBrw:Cargo
nColTo := oBrw:nColSel
ENDIF
// Initialize the drop FROM row and column variables
nColFrom := uDropInfo[1]
nRowFrom := uDropInfo[2]
i := nRowFrom
// Set column we are dragging from
nColPos := nColFrom
IF uDropInfo[3] == "B1"
// Do some of my own stuff..
// Set column we are dragging to
nColPos := nColTo
// Get subscript for new date/time
IF nColPos == 1
.. Do some things here
oBrw:Refresh()
ENDIF
ELSE
... Do some things
// Set column we are dragging to
nColPos := nColTo
oBrw:Refresh()
ENDIF
oBrw2:Refresh()
RETURN NIL
STATIC FUNCTION DragDrop2(uDropInfo,nRow,nCol,nKeyFlags,oBrw,oBrw2)
LOCAL nColPos
LOCAL x,y,i
LOCAL nRowFrom, nColFrom
LOCAL nRowTo, nColTo
LOCAL uButtonDown
local aPoint
// Dragging from time browse and dropping on timeless browse.
IF uDropInfo[3] == "B1"
// Reposition browse cursor to drop location
if nRow > 32000
nRow = - ( 65535 - nRow )
endif
if nCol > 32000
nCol = - ( 65535 - nCol )
endif
aPoint = { nRow, nCol }
aPoint = ClientToScreen( GetFocus(), aPoint )
ScreenToClient( oBrw2:hWnd, aPoint )
nRow := aPoint[1]
nCol := aPoint[2]
uButtonDown := oBrw2:lButtonDown(nRow, nCol, nKeyFlags)
oBrw2:lButtonUp(nRow, nCol, nKeyFlags)
// Unable to set row,col on browse. Must have dropped somewhere outside valid cell.
IF uButtonDown = nil
RETURN NIL
ENDIF
// Get the drop to row and column
nRowTo := oBrw2:Cargo
nColTo := oBrw2:nColSel
// Dragging & dropping on timeless browse
ELSE
// Reposition browse cursor to drop location
oBrw2:lButtonDown(nRow, nCol, nKeyFlags)
oBrw2:lButtonUp(nRow, nCol, nKeyFlags)
// Get the drop to row and column
nRowTo := oBrw2:Cargo
nColTo := oBrw2:nColSel
ENDIF
nColFrom := uDropInfo[1]
nRowFrom := uDropInfo[2]
i := nRowFrom
// Set column we are dragging from
nColPos := nColFrom
IF uDropInfo[3] == "B1"
... Do some things here
// Set column we are dragging to
nColPos := nColTo
ELSE
... Do some things here
// Set subscript into array based on column position
IF nColPos == 2
... Do some checking here
ELSE
// Couldn't determine, i.e. must be invalid
RETURN NIL
ENDIF
// Set column we are dragging to
nColPos := nColTo
ENDIF
... Do some things
RETURN NIL