Page 1 of 1

Problem on Drag 'n' drop with 17.11

PostPosted: Wed Dec 06, 2017 10:36 am
by AntoninoP
Hello,
My code of drag'n'drop does not working anymore.
I located the problem on this piece of code:
Code: Select all  Expand view
METHOD LButtonUp( nRow, nCol, nKeyFlags ) CLASS TControl

   local aPoint := { nRow, nCol }
   local lMoved := .f.

   ::lMouseDown = .f.

   if lDragging
      lDragging = .f.
      ReleaseCapture()

      aPoint = ClientToScreen( ::hWnd, aPoint )
      if aPoint[ 1 ] > 32768
         aPoint[ 1 ] -= 65535
      endif
      if aPoint[ 2 ] > 32768
         aPoint[ 2 ] -= 65535
      endif
      SendMessage( WindowFromPoint( aPoint[ 2 ], aPoint[ 1 ] ),;
                   FM_DROPOVER, nKeyFlags, nMakeLong( nRow, nCol ) )

      return nil
   endif

In the version 15.7 this piece of code was:
Code: Select all  Expand view
  if lDragging
      lDragging = .f.
      ReleaseCapture()

      aPoint = ClientToScreen( ::hWnd, aPoint )
      if aPoint[ 1 ] > 32768
         aPoint[ 1 ] -= 65535
      endif
      if aPoint[ 2 ] > 32768
         aPoint[ 2 ] -= 65535
      endif
      SendMessage( WindowFromPoint( aPoint[ 2 ], aPoint[ 1 ] ),;
                   FM_DROPOVER, nKeyFlags, nMakeLong( aPoint[ 1 ], aPoint[ 2 ] ) )

      return nil
   endif

The point passed from screen space to client space, of a unknowed window!

Does anyone remember the motivation of this change?

Personally I think is correct pass the coordinates in screen space...
I think could be usefull pass the origin window too...

Re: Problem on Drag 'n' drop with 17.11

PostPosted: Wed Dec 06, 2017 2:04 pm
by nageswaragunupudi
Mr Antonio

You made two points:
1) nMakeLong( aPoint[ 1 ], aPoint[ 2 ] ) makes more sense than nMakeLong( nRow, nCol )
and
2) The code in 15.07 used nMakeLong( aPoint[ 1 ], aPoint[ 2 ] ), where as subsequently it was changed to nMakeLong( nRow, nCol )

On the first point, I personally agree with you totally. Yes, that is very useful.
But you are not factually correct on the second point. The code has never been disturbed for many years. I just checked with 12.07.
Probably you might have modified control.prg of 15.07 for your use.

While once again I agree with you on which is better, the sad situation is that we are prevented from making any changes to retain backward compatibility.

Any advice?