>#include "FOXPRO.H" > >LOCAL loTheForm AS filesInGrid > >m.loTheForm = CREATEOBJECT("filesInGrid") >m.loTheForm.Show(1) > >m.loTheForm = .NULL. > >DEFINE CLASS filesInGrid AS Form > > ADD OBJECT grdFiles AS Grid WITH Top = 20, ReadOnly = .T. > > FUNCTION grdFiles.Init > > * The grid can receive draggable objects > This.OLEDropMode = 1 > > * create a cursor for the grid > CREATE CURSOR curFiles (displayname C(80), filename M) > > This.RecordSource = "curFiles" > This.ColumnCount = 1 > This.Column1.Width = This.Width - 24 > > ENDFUNC > > * when a data object is dragged over the grid > FUNCTION grdFiles.OLEDragOver > LPARAMETERS oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord, nState > > * if it is a file collection, say that we can receive a link to the files > IF m.oDataObject.GetFormat(CF_FILES) > m.nEffect = DROPEFFECT_LINK > * otherwise, we are not interested > ELSE > m.nEffect = DROPEFFECT_NONE > ENDIF > > ENDFUNC > > * when a data object is dropped over the grid > FUNCTION grdFiles.OLEDragDrop > LPARAMETERS oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord > LOCAL ARRAY laFiles [1] > LOCAL lnFile AS Integer > LOCAL lcFileName AS String > > * if it is a file collection, process the file collection > IF m.oDataObject.GetFormat(CF_FILES) > > IF m.oDataObject.GetData(CF_FILES, @m.laFiles) > > SELECT curFiles > > FOR m.lnFile = 1 TO ALEN(m.laFiles) > > * add the filename, if it is not already in the collection > LOCATE FOR filename == m.laFiles[m.lnFile] > IF !FOUND() > INSERT INTO curFiles (displayname, filename) ; > VALUES (JUSTSTEM(m.laFiles[m.lnFile]), m.laFiles[m.lnFile]) > ENDIF > > ENDFOR > > This.Refresh() > > ENDIF > > * signal that a link was performed > m.nEffect = DROPEFFECT_LINK > > * otherwise, we are not interested > ELSE > m.nEffect = DROPEFFECT_NONE > ENDIF > > ENDPROC > > >ENDDEFINE > >