Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MS Common Dialog - is there a way to return Path and lis
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00299346
Message ID:
00299893
Vues:
20
Hi George,

I already made the necessary changes. Now I have a function:
************************************************************
function File_Chooser
*  Description...... : Function invokes MS Common Dialog Control and
*					 : returns an array of files via parameters list.
*                    : Each element of the array contains one file...
*  Calling Samples...: dimension a_File[1]
*                    : lcPath = ""
*                    : lnFiles = File_Chooser(@a_File, @lcPath, DTitle, InDir)
*  Parameter List....: a_File, pPath, DTitle, InDir
********************************************************************
lparameter a_File, lcPath, DTitle, InDir
external array a_File

** Definition of Common Dialog flags

#define cdlOFNAllowMultiselect 0x200
*!*	Specifies that the File Namelist box allows multiple selections.
*!*	The user can select more than one file at run time by pressing
*!* the SHIFT key and using the UP ARROW and DOWN ARROW keys to select the desired files.
*!* When this is done, the FileName property returns a string containing the names
*!*	of all selected files.
*!* The names in the string are delimited by spaces.

oDialog = createobject('MSComDlg.CommonDialog')
* Set the flags for Multi-Select/Explorer
oDialog.MaxFileSize = 260
oDialog.Flags = 0x200 + 0x80000
oDialog.DialogTitle=DTitle
* Set filters
oDialog.filter = "All Files (*.*)|*.*|Database Files (*.dbf)|*.dbf|Index Files (*.cdx)|*.cdx"
* Specify default filter
oDialog.FilterIndex = 1

if not empty(InDir)
	oDialog.InitDir=InDir
endif

oDialog.ShowOpen

* Save the file name to a variable

lcFileName = oDialog.FileName

oDialog = null 

if empty(lcFileName) && User pressed a Cancel
	return 0
endif

lnpt = at(chr(0), lcFileName)
if lnpt > 0
	lcPath = left(lcFileName, lnpt - 1)
	lcFileName = substr(lcFileName, lnpt + 1)
	lnFiles = occurs(chr(0), lcFileName) + 1
	dimension a_File[lnfiles]
	lni = 0
	do while not empty(lcFileName)
		lni = lni + 1
		lnpt = at(chr(0), lcFileName)
		if lnpt > 0
			lcname = left(lcFileName, lnpt - 1)
			lcFileName = substr(lcFileName, lnpt + 1)
		else
			lcname = lcFileName
			lcFileName = ""
		endif
		a_File[lni] = lcname
	enddo
	lnFiles = alen(a_File, 1)
*!*	  FOR lni = 1 TO lnlast
*!*	    ? a_file[lni]
*!*	  NEXT
else
	lnFiles=1

	dimension a_File[lnFiles]
	lnPos=rat('\',lcFileName)
	lcPath=left(lcFileName,lnPos-1)
	lcname=substr(lcFileName,lnPos+1)
	a_File[1] = lcname
endif

return lnFiles
Hopefully, it's not for me 'stupid programmer', if even sometimes I am :)

>The stupid programmmer (yours truly), left the following out of the code
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform