Drag 'n' Drop support

Post Reply
AntoninoP
Posts: 347
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Drag 'n' Drop support

Post 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
AntoninoP
Posts: 347
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: Drag 'n' Drop support

Post 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.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Drag 'n' Drop support

Post by Antonio Linares »

Antonino,

Many thanks!

have you checked if your changes are backwards compatible ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
AntoninoP
Posts: 347
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: Drag 'n' Drop support

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

Re: Drag 'n' Drop support

Post by nageswaragunupudi »

Problem is backward compatibility.
All earlier software need to be modified
Regards

G. N. Rao.
Hyderabad, India
AntoninoP
Posts: 347
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: Drag 'n' Drop support

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Drag 'n' Drop support

Post by Antonio Linares »

Antonino,

Thanks anyhow :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
bpd2000
Posts: 153
Joined: Tue Aug 05, 2014 9:48 am
Location: India

Re: Drag 'n' Drop support

Post 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.
Regards, Greetings

Try FWH. You will enjoy it's simplicity and power.!
Post Reply