Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Primer on Drag drop
Message
From
30/08/2016 12:16:45
 
 
To
02/07/2016 16:48:10
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Network:
Windows Server 2012 R2
Database:
Visual FoxPro
Application:
Desktop
Virtual environment:
VMWare
Miscellaneous
Thread ID:
01637889
Message ID:
01640211
Views:
77
Hi Antonio,

I know it's been a while since you posted the code - just got around to this part of the project and implemented what you gave me - it worked perfect. Tamar pointed me to the Hackers guide which gave a good overview and then your code zeroed me in on exactly what I needed to put in where. All I needed to do was to add in some specific error trapping (in this case, since I was having them drop in a list of files from Windows Explorer - I just needed to trap if they had the file open in Word/Excel etc).

Again, thanks for the help as this got implemented a lot faster than I would have expected.

Albert

>>Hi all,
>>
>>Has anyone written any white papers on using drag and drop in VFP? Have *never* used this feature but finally a client has a use for it.
>>
>>Specifically, they want to be able to drag files from their file system overtop of a VFP grid and drop them to upload them to the grid. By "upload" I mean that I would get a list of the files (including full path) that I would then loop through and add to their documents database.
>>
>>(so if no one has a "primer", if anyone has code snippets I could look at, that would be great!
>>
>>Albert
>
>Hopefully, this will get you started.
>
>
>#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
>
>
Previous
Reply
Map
View

Click here to load this message in the networking platform