Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Not So Common Dialog
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00741435
Message ID:
00741463
Views:
28
Currently, I am unable to gain access to check the error log. The behavior specified to me is that a window flashes and goes away. Maybe I've assumed too much <g>. Below is the code I am using.

**********************************************************************
*-- GetMFile.prg
**********************************************************************
* Description .....: Function invokes MS Common Dialog Control and
* : 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 taFile[1]
* : lcPath = ''
* : lnFiles = GetMFile(@taFile, @lcPath, tcTitle, tcInDir)
* Parameter List ..: taFile, pPath, tcTitle, tcInDir
**********************************************************************
LPARAMETERS taFile, tcPath, tcTitle, tcInDir, tcFilter
EXTERNAL ARRAY taFile

*-- 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 loDialog, lcFileName, lnFiles, lcOldDir
lnFiles = 1
lcOldDir = SYS(5) + CURDIR() && Save current directory
loDialog = CreateObject('MSComDlg.CommonDialog')

WITH loDialog
*-- Set the flags for Multi-Select/Explorer
.MaxFileSize = 1640 && 820
.Flags = 0x200 + 0x80000
.DialogTitle = tcTitle

*-- Set filters
IF VarType(tcFilter) = 'C' AND !EMPTY(tcFilter)
.Filter = tcFilter
ELSE
.Filter = 'All Files (*.*)|*.*|Database Files (*.dbf)|*.dbf|Index Files (*.cdx)|*.cdx'
ENDIF

*-- Specify default filter
.FilterIndex = 1

IF NOT EMPTY(tcInDir)
.InitDir= tcInDir
ENDIF

.ShowOpen()

*-- Save the file name to a variable
lcFileName = .FileName
ENDWITH

loDialog = null
RELEASE loDialog
CD (lcOldDir) && Restore old directory

*-- Check if user pressed a Cancel button
IF EMPTY(lcFileName)
lnFiles = 0
ENDIF

IF lnFiles > 0
LOCAL lnPt, lnI, lcName
lnPt = AT(CHR(0), lcFileName)
IF lnPt > 0
tcPath = LEFT(lcFileName, lnPt -1)
lcFileName = SUBSTR(lcFileName, lnPt +1)
lnFiles = OCCURS(CHR(0), lcFileName) +1
DIMENSION taFile[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 = SPACE(0)
ENDIF
taFile[lni] = AddBS(tcPath) + lcName
ENDDO
lnFiles = ALEN(taFile, 1)
ELSE
lnFiles = 1
DIMENSION taFile[lnFiles]
lnPos = RAT('\', lcFileName)
tcPath = JustPath(lcFileName)
lcName = JustFName(lcFileName)
taFile[1] = AddBS(tcPath) + lcName
ENDIF
ENDIF

RETURN lnFiles
**********************************************************************


>What's the error?
>
>>I have a user that gets an error when the following code is executed:
>>
>>  loDialog = CreateObject('MSComDlg.CommonDialog')
>>
>>The user has Windows 2000 Pro. Is there something that I need to distribute or check for?
>>
>>Thanks.
>>Doug
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform