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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getfile() includes shortcuts

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
0
16
AU
Is there any way to remove shortcuts from a getfile() dialogue so that it only shows XLS files?

It says Files of type *.xls in the box.

And do folders have to show?

I'm using WIN 7 here but other users may still be on other windows versions.

Regards
GenDev
 
If you look into your VFP Help file for GETFILE() you will find how to specify getting only the XLS files listed that you mention above.

From VFP Help: GETFILE([cFileExtensions] [, cText] [, cOpenButtonCaption]
[, nButtonType] [, cTitleBarCaption])


Example: gcTable = GETFILE('DBF', 'Browse or Create a .DBF:', 'Browse', 1; 'Browse or Create')

Good Luck,
JRB-Bldr
 
I have looked at that and have this line in my code

importfile = Alltrim(Getfile('XLS', 'Select an .xls:', 'Select', 1, 'Select'))

I get the links and folders as mentioned before.

Thanks
 
GetFile() (and putfile()) are nifty bits of absolutely free code. They're terrific if they behave the way you want, but if you want more well, they behave the way they behave.

I suspect you'll always get directories. I know I'd be pretty miffed if Word's open file dialog didn't let me wander around my disk! As far as shortcuts go, how is VFP supposed to know what they're shortcuts *to*???? <g>

You might try the alternates. The common dialog control still works ( I have a dim memory of a similar dialog in Windows Scripting Host. (The great thing about standards is there are so many of 'em!)

If you're looking to stray that far from "standard" behavior, though, you probably ought to build your own. A listbox with RowSourceType=7 might get you there, although IIRC it does directory navigation too. But you can sure build an array and use that as your RowSource.
 
As all the shortcuts are *.lnk files (I think) - can getfile() be made to ignore them? Just a thought.

 
GenDev,

As you have discovered, GETFILE()lets you customise what you see in the "Files of type" control, but it gives you no control over what you see in the actual window - the place where you see the files and folders.

If you really only want to let your users choose from files in one specified directory, and you also want to control what files they see in that directory, then you need to create your own dialogue.

That shouldn't be too difficult. Create an ordinary VFP form. Add buttons, etc. as required.

To get the names of the files that you want to show, use the ADIR() function. This generates an array of filenames, which you can maniupulate in any way you like.

To actually show the files in your form, you could use a lisbtbox, or perhaps a grid. If you really want to do it well (at the cost of a little more effort), use my freeware SimpleList control (see which lets you exactly mimic the file area that you see in the GETFILE() dialogue.

On the other hand, perhaps you should just use GETFILE() as it stands. It does have the benefit of working in exactly the same way as the File Open dialogue in most other Windows applications.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thanks to all for some good inputs.
re - shortcuts
I had my sample xls file on the desktop - hence the many shortcuts that were listed. (Nicely grouped using 'fences' s/w on my 3840 X 1024 - 3 monitor display - before anyone tells me of my folly in filling a desktop with shortcuts).

Normally my users will have their target file in a normal folder so I've decided to take Mike's advice and stick with the getfile() control.

GenDev
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top