Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select multiple files
Message
 
 
To
04/07/2001 04:29:55
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00526491
Message ID:
00526829
Views:
22
>>I have a running VFP6 app which allows the user to select a file using GETFILE. Now my customer wants to be able to select multiple files using shift or control - the normal windows multiple file select. Does anyone have a recommendation? Can GETFILE be configured to allow multiple selects? Is there another choice?
>>Thanks in advance for any help.
>
>Graham,
>If they're on same dir you could just use a listbox with rowsourcetype files and multiselect .t.
>If not you could use GetFile() in a loop till it returns an empty string and add each selected to a grid, listbox to show.
>You could use a treeview with checkboxes, populate it with files as well as dirs (for fast building check UT magazine 1st issue).
>You could gather dirs+files to a cursor and use a multiselect control (listbox or MultiselectGrid class).
>You could directly invoke windows explorer and use OLEDragDrop (check sample in solution.app\What's new\Fun with OLEdd).
>Cetin

You can use CommonDialog control, which allows multiselection: (code idea belongs to George Tasker):
************************************************************
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.
local oDialog
oDialog = createobject('MSComDlg.CommonDialog')
* Set the flags for Multi-Select/Explorer
with oDialog
     .MaxFileSize = 260
     .Flags = 0x200 + 0x80000
     .DialogTitle=DTitle
* Set filters
     .filter = "All Files (*.*)|*.*|Database Files (*.dbf)|*.dbf|Index Files (*.cdx)|*.cdx"
* 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

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

lnpt = at(chr(0), m.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
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform