Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File Chooser doesn't want to disappear
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
File Chooser doesn't want to disappear
Miscellaneous
Thread ID:
00581793
Message ID:
00581793
Views:
58
Hi everybody,

I have this code in form's button:
********************************************************************
*  Description.......: cmdSelectFiles.Click
*  Calling Samples...: 
*  Parameter List....: 
*  Created by........:  
*  Modified by.......: Nadya Nosonovsky 11/14/2001 04:09:00 PM
********************************************************************
local DTitle, lcFilter, lcPath, lcStartDir, lnFiles, lnI
local array laTbls[1]
laTbls[1]=''
DTitle = "Select BldMstr like Files to check structure..."
* Text (*.txt)|*.txt|Pictures (*.bmp;*.ico)|*.bmp;*.ico
lcFilter = "BldMstr Files (*.dbf)|*.dbf|All Files (*.*)|*.*"
lcPath=''
lcStartDir= "\redp\work\"
dimension thisform.aTbls[1]
lnFiles = File_Chooser(@laTbls, @lcPath, m.DTitle, m.lcStartDir, m.lcFilter)

if m.lnFiles > 0
   for lnI=1 to m.lnFiles
       thisform.aTbls[m.lnI]=addbs(m.lcPath)+laTbls[m.lnI]
   next
endif
thisform.nSelFiles =m.lnFiles
And this is File_Chooser.prg:
************************************************************
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 = 820
	.Flags = 0x200 + 0x80000
	.DialogTitle= m.DTitle
* 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 not empty(m.InDir)
		.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
When I click on button, dialog appears, I chose file(s) and click Open button, but the dialog doesn't disapper and remain on the screen. What should I do to fix this problem? Form is a modal form. Do I need to play with AutoYeld or something like this?

Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform