Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Drop file on a form for app to save it
Message
From
13/03/2018 11:00:43
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01658695
Message ID:
01658703
Views:
59
>>>Hi,
>>>
>>>I was wondering if it is possible to build the following functionality into my VFP 9 application.
>>>
>>>User would drop a file from Windows Explorer (e.g. PDF document) on a form of the VFP application and the application saves this file into a folder (e.g. \\servername\pdf_files)?
>>>
>>>Is this possible and if yes, how?
>>>
>>>TIA.
>>
>>Hi, Dmitry
>>
>>This will give a starting point:
>>
>>
>>LOCAL Demo AS PDFDragNDropper
>>
>>m.Demo = CREATEOBJECT("PDFDragNDropper")
>>m.Demo.Show(1)
>>
>>DEFINE CLASS PDFDragNDropper AS Form
>>
>>	OLEDropMode = 1
>>	* set this to the location of the repository
>>	Repository = ADDBS(SYS(2023)) + "PDFRepository"
>>
>>	FUNCTION Init
>>		IF !DIRECTORY(This.Repository)
>>			MKDIR (This.Repository)
>>		ENDIF
>>	ENDFUNC
>>
>>	FUNCTION OLEDragOver
>>	LPARAMETERS oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord, nState
>>	LOCAL ARRAY DragFiles(1)
>>
>>		IF m.nState = 0
>>			IF m.oDataObject.GetData(15, @m.DragFiles) AND UPPER(JUSTEXT(m.DragFiles(1))) == "PDF"
>>				This.OLEDropHasData = 1
>>				This.OLEDropEffects = 1
>>			ENDIF
>>		ELSE
>>			IF m.nState = 1
>>				This.OLEDropHasData = -1
>>			ENDIF
>>		ENDIF
>>
>>	ENDFUNC
>>
>>	FUNCTION OLEDragDrop
>>	LPARAMETERS oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord
>>	LOCAL ARRAY DragFiles(1)
>>	LOCAL SourceFile AS String
>>	LOCAL DestinationFile AS String
>>
>>		DIMENSION m.DragFiles(1)
>>		IF m.oDataObject.GetData(15, @m.DragFiles)
>>			WAIT WINDOW "Copying.." NOWAIT NOCLEAR
>>			FOR EACH m.SourceFile IN m.DragFiles
>>				IF UPPER(JUSTEXT(m.SourceFile)) == "PDF"
>>					m.DestinationFile = ADDBS(This.Repository) + JUSTFNAME(m.SourceFile)
>>					STRTOFILE(FILETOSTR(m.SourceFile), m.DestinationFile, 0)
>>				ENDIF
>>			ENDFOR
>>			WAIT WINDOW "Done!" NOWAIT
>>			m.nEffect = 1
>>		ELSE
>>			m.nEffect = 0
>>		ENDIF
>>
>>	ENDFUNC
>>
>>ENDDEFINE
>>
>
>Hi Antonio,
>
>First, thank you very much for your message. I tried your code (without any changes and without understanding it) and when I drop a file onto the sample form, I am trying to figure out where did the file was copied. I will carefully review your code and I am sure it will become more clear.
>Again, thank you.

There is a property in the form, Repository. That's to where the files are getting copied. Normally, the files will go to %localappdata%\Temp\PDFRepository.

You can build a form visually, just set OLEDropMode to 1, add the Repository property and set it to were you need to drop the files, and copy the code to OLEDragOver and OLEDragDrop events.
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform