Hello,
I modified fiveWin for a IMHO better support for drag'n'drop:
On
window.prg
changed
DATA bCommNotify, bMenuSelect, bZip, bUnZip, bDropOver
in
DATA bCommNotify, bMenuSelect, bZip, bUnZip, bDropOver, bCanDrop, bDropOut
On
control.prg
Added:
DATA oWndOldOver // DropOver destination window last mousemove
Changed
SendMessage( WindowFromPoint( aPoint[ 2 ], aPoint[ 1 ] ),;
FM_DROPOVER, nKeyFlags, nMakeLong( nRow, nCol ) )
In
SendMessage( WindowFromPoint( aPoint[ 2 ], aPoint[ 1 ] ),;
FM_DROPOVER, nKeyFlags, nMakeLong( aPoint[ 1 ], aPoint[ 2 ] ) )
in this way dropOver receives screen coordinate.
changed
local nOldRow, nOldCol, hOver, oWndOver, aPoint
in
local nOldRow, nOldCol, hOver, oWndOver, aPoint, lCanDrop
and
hOver = WindowFromPoint( aPoint[ 2 ], aPoint[ 1 ] )
if hOver == ::hWnd
SetCursor( ::oDragCursor:hCursor )
else
oWndOver = oWndFromHWnd( hOver )
if oWndOver == nil .or. oWndOver:bDropOver == nil
CursorNO()
else
SetCursor( ::oDragCursor:hCursor )
endif
endif
in
hOver = WindowFromPoint( aPoint[ 2 ], aPoint[ 1 ] )
oWndOver = nil
lCanDrop := .T.
if hOver != ::hWnd
oWndOver = oWndFromHWnd( hOver )
if oWndOver == nil .or. ( oWndOver:bCanDrop == nil .and. oWndOver:bDropOver == nil )
lCanDrop := .F.
else
if oWndOver:bCanDrop != nil
lCanDrop := Eval( oWndOver:bCanDrop, aPoint[1], aPoint[2], nKeyFlags )
endif
endif
endif
if ::oWndOldOver!=nil .and. hOver != ::oWndOldOver:hWnd .and. ::oWndOldOver:bDropOut != nil
Eval( ::oWndOldOver:bDropOut, aPoint[1], aPoint[2], nKeyFlags )
ENDIF
::oWndOldOver := oWndOver
if lCanDrop
SetCursor( ::oDragCursor:hCursor )
else
CursorNO()
endif
In this way receiver has callbacks: bCanDrop on mouse move and decide if receive or not the callback and bDropOut when dropping going out.