Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Drop file on a form for app to save it
Message
De
13/03/2018 10:47:40
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01658695
Message ID:
01658699
Vues:
98
This message has been marked as the solution to the initial question of the thread.
>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
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform