Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Drop file on a form for app to save it
Message
 
 
À
13/03/2018 11:00:43
Antonio Lopes (En ligne)
BookMARC
Coimbra, Portugal
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01658695
Message ID:
01658705
Vues:
46
>>>>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.

Thank you. I am equally amazed of your knowledge and the VFP's having this OleDragDrop built right into each form.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform