Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Drag and Drop from Windows Explorer?
Message
 
To
09/11/2000 13:46:21
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00439831
Message ID:
00439993
Views:
14
Hi John,

Your question piqued my curiosity so I went on a voyage of discovery <g>. Here is a form that deminstrates a technique to do what you want.
*!* These constants are in (home() + 'foxpro.h')
*!*	#DEFINE CF_TEXT	1
*!*	#DEFINE CF_FILES	15

*!*	#DEFINE DROPEFFECT_NONE	0 
*!*	#DEFINE DROPEFFECT_COPY	1
*!*	#DEFINE DROPEFFECT_MOVE	2 
*!*	#DEFINE DROPEFFECT_LINK 	4 

*!*	#DEFINE DROPHASDATA_VFPDETERMINE	-1
*!*	#DEFINE DROPHASDATA_NOTUSEFUL		0
*!*	#DEFINE DROPHASDATA_USEFUL			1

#INCLUDE foxpro.h

#DEFINE CR	chr(13) + chr(10)

oForm = createobject('form1')
oForm.Show(1)

DEFINE CLASS form1 AS form

	DoCreate = .T.
	OLEDropMode = 1
	Caption = "Drag-Drop Target Test Form"
	MaxButton = .F.
	MinButton = .F.
	Name = "Form1"


	ADD OBJECT edtresult AS editbox WITH ;
		OLEDropMode = 2, ;
		Height = 235, ;
		Left = 10, ;
		ReadOnly = .T., ;
		Top = 10, ;
		Width = 355, ;
		Name = "edtResult"


	PROCEDURE OLEDragDrop
		LPARAMETERS oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord

		local lcText
		lcText = ''

		do case
		case oDataObject.GetFormat(CF_FILES)
			* If there's been a file or filesd dropped get the file names
			local lcFileName, laFiles[1]
			=oDataObject.GetData(CF_FILES, @laFiles)
			if alen(laFiles) > 0
				lcText = 'The following files were dropped:'
				for each lcFileName in laFiles
					lcText = lcText + CR + lcFileName
				endfor
			else
				lcText = 'No files were dropped on the form'
			endif

		case oDataObject.GetFormat(CF_TEXT)
			lcText = 'The following text was dropped on the form' + CR + ;
				oDataObject.GetData(CF_TEXT)
		otherwise
			lcText = 'No valid data found'

		endcase

		this.edtResult.Value = lcText
	ENDPROC


	PROCEDURE OLEDragOver
		LPARAMETERS oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord, nState


		* if this is not the first time the event has fired, just return
		if nState <> 0
			NODEFAULT
			return
		endif

		* check out the contents of the data object and enable them if it's appropriate

		do case oDataObject.GetDataFormat(CF_FILES) or oDataObject.GetDataFormat(CF_TEXT)
			this.oleDropHasData = DROPHASDATA_USEFUL
			this.OLEDropEffects = DROPEFFECT_COPY + DROPEFFECT_MOVE + DROPEFFECT_LINK
		otherwise
			this.oleDropEffects = DROPHASDATA_NOTUSEFUL
			this.OLEDropEffects = DROPEFFECT_NONE
		endcase
		
		*****
		* GOT TO HAVE THIS, OTHERWISE VFP OVERRIDES ALL YOUR GOOD WORK!
		*****
		NODEFAULT
	ENDPROC


ENDDEFINE
HTH

Cheers,

Andrew

>I need to be able to drag a file from Windows Explorer, drop it on a place in a vfp6 form and have the system parse
>out of the file name several important items. Can anyone out there point me in the correct dirrection? I just needs to know
>how to handle the drag and drop aspect. If the system could just return the name and path of the file, I can handle the
>rest. Thanx in advance....
>
>
>John Dennis


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform