Page 1 of 1

Drag 'n' Drop support

Posted: Fri Apr 24, 2015 4:59 pm
by AntoninoP
Hello,
I am watching the drag'n'drop support in five win and have some notes:
* bDropOver receives the nRow and nCol relatives of sender control
* There is no callback for receiver during mouse move

In my application I am dropping in a list, and I want that the position in the list is based on mouse release position.
I want too draw a line where this new element will be placed.
Now it is not possible.

Regards,
Perry

Re: Drag 'n' Drop support

Posted: Wed Apr 29, 2015 10:34 am
by AntoninoP
Hello,
I modified fiveWin for a IMHO better support for drag'n'drop:

On window.prg
changed

Code: Select all

   DATA   bCommNotify, bMenuSelect, bZip, bUnZip, bDropOver
in

Code: Select all

   DATA   bCommNotify, bMenuSelect, bZip, bUnZip, bDropOver, bCanDrop, bDropOut
On control.prg
Added:

Code: Select all

DATA   oWndOldOver            // DropOver destination window last mousemove
Changed

Code: Select all

      SendMessage( WindowFromPoint( aPoint[ 2 ], aPoint[ 1 ] ),;
                   FM_DROPOVER, nKeyFlags, nMakeLong( nRow, nCol ) )
In

Code: Select all

      SendMessage( WindowFromPoint( aPoint[ 2 ], aPoint[ 1 ] ),;
                   FM_DROPOVER, nKeyFlags, nMakeLong( aPoint[ 1 ], aPoint[ 2 ] ) )
in this way dropOver receives screen coordinate.
changed

Code: Select all

   local nOldRow, nOldCol, hOver, oWndOver, aPoint
in

Code: Select all

   local nOldRow, nOldCol, hOver, oWndOver, aPoint, lCanDrop
and

Code: Select all

            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

Code: Select all

            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.

Re: Drag 'n' Drop support

Posted: Wed Apr 29, 2015 1:30 pm
by Antonio Linares
Antonino,

Many thanks!

have you checked if your changes are backwards compatible ?

Re: Drag 'n' Drop support

Posted: Wed Apr 29, 2015 4:03 pm
by AntoninoP
Yes, I tried some samples by fivewin.
When i have time i will post an example with drag'n'drop with listview and insertionMark.

Re: Drag 'n' Drop support

Posted: Wed Apr 29, 2015 5:21 pm
by nageswaragunupudi
Problem is backward compatibility.
All earlier software need to be modified

Re: Drag 'n' Drop support

Posted: Thu Apr 30, 2015 7:20 am
by AntoninoP
Hello,
I removed all my modifications on FiveWin code, put a good drag'n'drop support is too complicated.
In my program I do it in mouse events. In this way I have all control I need,
Regards,
Antonino Perricone

Re: Drag 'n' Drop support

Posted: Thu Apr 30, 2015 7:43 pm
by Antonio Linares
Antonino,

Thanks anyhow :-)

Re: Drag 'n' Drop support

Posted: Tue Jul 07, 2015 11:18 am
by bpd2000
AntoninoP wrote:Yes, I tried some samples by fivewin.
When i have time i will post an example with drag'n'drop with listview and insertionMark.