Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getfile()
Message
 
To
07/02/2002 16:13:05
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Miscellaneous
Thread ID:
00616954
Message ID:
00617020
Views:
40
>Timothy,
>
>You can use the MS Common Dialog, and get the same dialog that is used elsewhere in Windows apps. See Thread #495437 Message #495505 for sample code; you will have to make a couple of syntax corrections to it because of recent changes at UT (> --> change to the greater than symbol, && --> change to &&)
>
>Look at the filter line...it is what you have to change for your requirement.
>
>>Greetings, I am employing the getfile to display the dialogue for a user to select files of type DBF. However I want to restrict the list so that only dbf files beginning with 02 show up. For example 02025vs.dbf. Is there a way or does the user have to manually type this?

so what you're saying, there's no conventional way of doing this, so Nadya's prg kind of simulates the true getfile()? I got it to work using below code.



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
.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
"Build a man a fire, and he's warm for a day.
Set a man on fire, and he's warm for the rest of his life."
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform