Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Common Dialog: ShowOpen() errors out
Message
 
 
À
21/12/2004 14:53:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
00971064
Message ID:
00971226
Vues:
44
This message has been marked as a message which has helped to the initial question of the thread.
>>Is it like some other ActiveX controls, were if you subclass them, the subclass will work directly, while the original won't?
>
>Haven't tried. All I saw is that if you drop it in a container (form) it works, just as it does in the Solution Samples provided. If you go directly with CreateObject() (no subclassing), it bombs.
>
>Anyway, I delivered the little utility they needed today (a quick job to select multiple text files with text logs from a Stratus minicomputer, and parse out the transactions they are looking for). It is just an SDI form with a few controls plus the ActiveX. It returns a bunch of files in CSV format.
>
>Simple, fast and effective. And people are always amazed around here that VFP can do that when it is not working as a database or with data! {bg}

The code bellow works, though it's a little bit outdated. But if you want to deploy, you would need to subclass CommonDialog (at least it was the case in prior versions of VFP):
************************************************************
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
*  Created by George Tasker and modified by Nadya Nosonovsky
********************************************************************
lparameter a_File, tcPath, DTitle, InDir, tcFilter
external array a_File
** Definition of Common Dialog flags see in CommonDlg.h file
#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.
local oDialog, lcFileName, lnFiles, lcOldDir
lnFiles = 1
lcOldDir = sys(5)+curdir() && Save current directory
oDialog = createobject('MSComDlg.CommonDialog')
with oDialog
* Set the flags for Multi-Select/Explorer
	.MaxFileSize = 1640 && 820
	.Flags = 0x200 + 0x80000
	if vartype(m.DTitle)='C'
   		.DialogTitle = m.DTitle
   	else
   	    .DialogTitle = "Choose files"
   	endif     	
* Set filters
	if vartype(m.tcFilter)='C' and !empty(m.tcFilter)
		.filter = m.tcFilter
	else
		.filter = "All Files (*.*)|*.*|Database Files (*.dbf)|*.dbf|Index Files (*.cdx)|*.cdx"
	endif
* Specify default filter
	.FilterIndex = 1
	if vartype(m.InDir)='C'
		.InitDir= m.InDir
	endif
	.ShowOpen
* Save the file name to a variable
	lcFileName = .FileName
endwith
oDialog = null
release oDialog
cd (m.lcOldDir) && Restore old directory

if empty(m.lcFileName) && User pressed a Cancel button
	lnFiles = 0
endif
if m.lnFiles > 0
	local lnPt, lnI, lcName
	lnPt = at(chr(0), m.lcFileName)
	if m.lnPt > 0
		tcPath = left(m.lcFileName, m.lnPt - 1)
		lcFileName = substr(m.lcFileName, m.lnPt + 1)
		lnFiles = occurs(chr(0), m.lcFileName) + 1
		dimension a_File[m.lnFiles]
		lnI = 0
		do while not empty(m.lcFileName)
			lnI = m.lnI + 1
			lnPt = at(chr(0), m.lcFileName)
			if m.lnPt > 0
				lcName = left(m.lcFileName, m.lnPt - 1)
				lcFileName = substr(m.lcFileName, m.lnPt + 1)
			else
				lcName = m.lcFileName
				lcFileName = ""
			endif
			a_File[m.lni] = m.lcName
		enddo
		lnFiles = alen(a_File, 1)
	else
		lnFiles=1
		dimension a_File[m.lnFiles]
		lnPos=rat('\',m.lcFileName)
		tcPath=justpath(m.lcFileName)
		lcName=justfname(m.lcFileName)
		a_File[1] = m.lcName
	endif
endif
return m.lnFiles
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform