Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need to select a group of files 2

Status
Not open for further replies.

dstema

Programmer
May 6, 2001
20
0
0
US
Hi everybody,
I need a way (like getfile()) to select multiple files. The user is supposed to be able to easily pick up one or more files (txt in my case). Files are not necessary in the same director/drive.
Any word is welcome.
Thanks.
 
If you use a combobox to provide the list to the user, you can use thisform.cboList.AddItem(cFilename) within a form to populate the combobox with the filenames.

You will have to preceed that with some means of determining which files are to be included.

Don
dond@csrinc.com

 
Hi DStema,

One possibility would be to use ADIR() to fill an array with the files that you want. If you want to get files from more than one directory, call ADIR() each time, then write code to combine the resulting arrays into one big one.

Once you have the array, create a list box. Use the array as its Rowsource. Set its MultiSelect property to .T.

The user will then be able to multi-select by holding down the Ctrl key while clicking.

Mike Lewis
Edinburgh, Scotland
 
You could consider using the common dialog control also. Drop an instance of it on your form, and in the Init of the dialog, add this:

This.Flags = 0x200 + 0x80000 + 0x200000
-where-
0x200 = multiselect
0x80000 = explorer type window
0x200000 = long file names

Add a form property like:
cFileNames

Then add a command button with this in it:

THISFORM.olecommdlg.showopen
ThisForm.cFileNames = ThisForm.cFileNames + ;
ALLTRIM(THISFORM.olecommdlg.filename)

Each time the user selects files and clicks 'Open', the file names will be appended to ThisForm.cFileNames.
Dave S.
 
Dave,

That is really neat, I needed to add .value to the cfilenames object references, but it works.

Code:
ThisForm.cFileNames.value = ThisForm.cFileNames.value + ;
     ALLTRIM(THISFORM.olecommdlg.filename)

The value returned from multiple filenames would need to processed a little to extract all the names but it is much better than using a combo box!

Many thanks

Regards

Griff
Keep [Smile]ing
 
Thanks.

I figured once someone tried it and saw the returns they would know there would be some parsing required, so I didn't bother to mention it.
Dave S.
 
I got a property flags not found error ... any clues why ?

Thx
JF
 
The flags are an attribute of the common control dialog.

It is possible that you are putting the code in the init method of the form instead of the dialog.

HTH Regards

Griff
Keep [Smile]ing
 
Nope... did it all again same error....VFP7

Code

This.Flags = 0x200 + 0x80000 + 0x200000

Definitely in init of Dialog

Should Flags show up in 'properties' of Dialog .. if so it doesn't.
 
Question


In the properties of _system.vcx can some one tell me the description for the flags in the little box below,,,, there is definitely nothing labelled flags.. If you can tell me what it says I can try and match it up !

In the c_comdlg I got

afilenames(1)
afilterlist(1,2)
customfilter
cdefaultextension

etc etc
 
FoxEgg

afilenames(1) - an array holding the filename(s) selected in the dialog.

nFileCount will return the number of files selected.

afilterlist(1,2) - The second part of the filtered filenames list ie [*.bmp;*.doc;*.gif;*.jpg;*.jpeg], separated by ';' as a delimiter

customfilter, should be ccustomfilter, the custom filter created by the user

cdefaultextension - the default file ext to display by the dialog
FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
FoxEgg,

If you right-click on the control, and select 'CommonDialog Properties', yes. There is text box for Flags. It will probably be set at 0.

Just for reference, I am using
"Microsoft Common Dialog Control, version 6.0"

Maybe different/earlier versions doesn't have flags? Dunno.
Dave S.
 
Thanks Chris and Dave..

Sorry Chris my request was shonky ...

I cannot find the property FLAGS in this common control dialog

I have these listed below (plus others) with the descriptions like you descibed....

BUT NO PROPERTY FLAGS

afilenames(1)
afilterlist(1,2)
customfilter
cdefaultextension
flags <<<----------------- IS NOT THERE

what I was hoping was that someone who had this property, could tell me what FLAGS was described as... maybe one of these other properties was the one I wanted/needed.

I have to try Dave's suggestion now,,,,

JF




 
Dave I must be losing it...

I have the control _COMDLG1 on a form with a single command button...

I right click on the control...

I get the usual options... Undo Cut Copy and Properties BUT NOTHING LABELLED 'CommonDialog Properties' and hence no text box for Flags....(I looked in the Properties... and there is no Flags either...


among the Properties... it goes
etc etc
dialoghandler
integertostring
etc etc

I expect FLAGS to be between these two (alphabetically)

OK.. so then I use

<alt> Tools -> Component Gallery -> Foundation Classes -> Dialogs -> Common Dialog (right click) Properties is there but still nothing labelled 'CommonDialog Properties' !!!

Is this a version thing with VFP7 ?
Am I using the wrong control ?
Should I increase my Prozac ?

John

 
I'm not using the _comdlg class of th _system.vcx. I' using the Common Dialog control in Tools Options.

From the main menu:
Tools -> Options -> Controls -> Microsoft Common Dialog Control
Click the checkbox on the left.

You will now have it listed in the ActiveX controls in the 'Form Controls' toolbar.
Dave S.
 
Right... got that..

I add an OLEcontrol..
put in the Microsoft Common Dialog Control (version 6)

open the init event of this OLEcontrol
and add to the init event

this.Flags = 0x200 + 0x80000 + 0x200000

add a command box to form
add to the click event

THISFORM.olecommdlg.showopen
ThisForm.cFileNames = ThisForm.cFileNames.value + ;
ALLTRIM(THISFORM.olecommdlg.filename.value)

Run form...

get an error on the olecommdlg and so I change that to OLECONTROL1..

It works... (Prozac reduced)

But still a few little headaches... Must go to work....

Thank you so much for the help.

I have no idea how you guys do this !!

John






 
Sounds like the title to a new book:

&quot;Software Developement and the Miracles of Chemistry&quot;

:)
Dave S.
 
John, Dave

The following is an alternative way using _COMDLG - there are no flags set. The selected filenames are returned from the array aFileNames.

WITH .cusCommonDialog
[tab].lAllowMultiSelect = .T.
[tab].cFileName = []
[tab].cInitialDirectory = ALLTRIM(USER.s_folder)
[tab].cTitlebarText = [Select source files]
[tab].aFilterList[1,1] = [Source (bmp,doc,gif,jpg)]
[tab].aFilterList[1,2] = [*.bmp;*.doc;*.gif;*.jpg;*.jpeg]
[tab].nFileCount = 0
[tab].ShowDialog()
ENDW

FOR i = 1 TO ALEN(.cusCommonDialog.aFileNames,1)
[tab]INSERT INTO AUTO_CREATE (filename) VALUES (UPPER(SYS(5));
[tab][tab]+ LOWER(ADDBS(SYS(2003)));
[tab][tab]+ UPPE(SUBS(.cusCommonDialog.aFileNames[1,i],1,1));
[tab][tab]+ LOWE(SUBS(.cusCommonDialog.aFileNames[1,i],2)))
ENDF
FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top