MARIO ("THE HOSE HEAD"<g>),
Here is code from a prototype I built to demonstrate to a customer how drag and drop could be used within a grid.
...
Step 1: I set my grid's OLEDropMode to 1 (Enabled).
...
Step 2: Here's a snippet from my grid's OLEDragDrop method:
* portions of this code are from an example posted on UT by Cetin
LPARAMETERS oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord
ThisForm.LockScreen = .T.
With This
nXCoord_In = Mcol(Wontop(),3)
nYCoord_In = Mrow(Wontop(),3)
Store 0 To nWhere_Out , nRelRow_Out , nRelCol_Out , nView_Out
If .GridHitTest(nXCoord_In, nYCoord_In, @nWhere_Out, @nRelRow_Out, @nRelCol_Out) And nWhere_Out = 3
.ActivateCell(nRelRow_Out, nRelCol_Out)
local lcRecord
lcRecord = "Dropped on record = " + alltrim( ALIST.cFullTitle )
else
lcRecord = "Ignoring drop"
Endif
Endwith
* NOTE: We activate dropped record vs. returning to original record.
ThisForm.LockScreen = .F.
* messagebox( "Dropped on record = " + lcRecord )
set message to lcRecord
...
Step 3: Here's a snippet from my grid's OLEDragStart() method:
LPARAMETERS oDataObject, nEffect
local lcData
lcData = alltrim( ALIST.cFullTitle )
oDataObject.SetData( lcData, 1 )
nEffect = 1 + 2 && copy + move
set message to "Start Drag"
...
You will have to modify these snippets to match your grid table. My examples just report the drag drop attempt - they don't actually reposition records.
One hassle you will have is when you try to drag a record to a new position within a large grid and the destination record is not visible within the grid's window. VFP's grid will NOT auto-scroll when you move to the top or bottom edges of the grid.
One way you might provide an auto-scroll capability would be to place shape controls at the top and bottom of a grid and have these shape control's trigger grid scroll's in their OLEdragover events (making sure that the source of drag over is the grid control and not another control).
Hope this helps!
Malcolm