Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Drop file on a form for app to save it
Message
From
14/03/2018 11:21:11
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01658695
Message ID:
01658746
Views:
58
Hi
this is another version of Antonio's dragNdropper.works with all enabling apps for this operation.
*!*	can drag & drop any extension file form explorer to this form.
*!*	-can specify an extension  and drag & drop
*!*	-can change currently this extension  and drag & drop
*!*	-can select *.* for all extensions files  and drag & drop (any file).its the default.
*!*	source can be window explorer, firefox( transformed in BMP!)...... for apps enabling these  operations (IE & Edge dont enable it for ex.).
*!*	all files dragged are gathered in a temp foler "yfolder"
*!*	can explorer it to see the captured files.
		
PUBLIC oform
oform=NEWOBJECT("dragNdropper")
oform.Show
RETURN
*
DEFINE CLASS dragNdropper AS form
	BorderStyle = 0
	Top = 172
	Left = 151
	Height = 97
	Width = 540
	ShowWindow = 2
	Caption = "Drag & drop any  files to thisform. from the  windows explorer"
	AlwaysOnTop = .T.
	Name = "Form1"

	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 48, ;
		Left = 345, ;
		Height = 37, ;
		Width = 169, ;
		Caption = "Explorer DragnDrop pdf files", ;
		Name = "Command1"

	ADD OBJECT label1 AS label WITH ;
		AutoSize = .T., ;
		WordWrap = .T., ;
		BackStyle = 0, ;
		Caption = "Type an Extension file or  *.* for all ext.", ;
		Height = 32, ;
		Left = 12, ;
		Top = 12, ;
		Width = 105, ;
		Name = "Label1"

	ADD OBJECT text1 AS textbox WITH ;
		FontBold = .T., ;
		Value = "*.*", ;
		Height = 25, ;
		Left = 127, ;
		Top = 13, ;
		Width = 72, ;
		Name = "Text1"

	ADD OBJECT label2 AS label WITH ;
		AutoSize = .T., ;
		FontBold = .T., ;
		FontSize = 20, ;
		BackStyle = 0, ;
		Caption = "?", ;
		Height = 35, ;
		Left = 516, ;
		MousePointer = 15, ;
		Top = 0, ;
		Width = 19, ;
		ForeColor = RGB(128,0,64), ;
		Name = "Label2"

	PROCEDURE 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
					do case
				    case UPPER(JUSTEXT(m.SourceFile)) ==upper(allt( thisform.text1.value))  
							m.DestinationFile = ADDBS(This.yfold) + JUSTFNAME(m.SourceFile)
							STRTOFILE(FILETOSTR(m.SourceFile), m.DestinationFile, 0)
		            case allt( thisform.text1.value)=="*.*"
		                   m.DestinationFile = ADDBS(This.yfold) + JUSTFNAME(m.SourceFile)
							STRTOFILE(FILETOSTR(m.SourceFile), m.DestinationFile, 0)
					ENDCASE
					ENDFOR
					WAIT WINDOW "Done!" NOWAIT
					m.nEffect = 1
				ELSE
					m.nEffect = 0
				ENDIF
	ENDPROC

	PROCEDURE 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))) == upper(allt( thisform.text1.value))  or  allt( thisform.text1.value)='*.*'
						This.OLEDropHasData = 1
						This.OLEDropEffects = 1
					ENDIF

				ELSE
					IF m.nState = 1
						This.OLEDropHasData = -1
					ENDIF
				ENDIF
	ENDPROC


	PROCEDURE Init
		_screen.windowstate=1
		this.OLEDropMode = 1
			* create a folder to gather all dragNdrop files
		this.addproperty("yFold",	ADDBS(SYS(2023)) + "yfolder")
		IF !DIRECTORY(This.yFold)
			MKDIR (This.yfold)
		ENDIF
	ENDPROC

	PROCEDURE Destroy
		clea events
	ENDPROC

	PROCEDURE command1.Click
		try
		local m.x
		m.x=thisform.yfold
		run/n  explorer &x
		catch
		endtry
	ENDPROC

	PROCEDURE label2.Click
		local m.myvar
		text to m.myvar pretext  7 noshow
		can drag & drop any extension file form explorer to this form.
		-can specify an extension  and drag & drop
		-can change currently this extension  and drag & drop
		-can select *.* for all extensions files  and drag & drop (any file).its the default.
		source can be window explorer, firefox( images are transformed in BMP+renamed !)...... for apps enabling these operations.
		all files dragged are gathered in a temp folder  "yfolder"
		can explorer it to see the captured files.
		endtext
		messagebox(m.myvar,0+32+4096)
	ENDPROC

ENDDEFINE
*
*-- EndDefine:dragNdropper
can also read in my blog (02/2017): http://yousfi.over-blog.com/2017/02/oledragdrop-with-treeview-textbox-listbox-from-windows-explorer.html
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform