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

Fox26Win File Open Dialog with Long File Names

Status
Not open for further replies.

Gene77532

Programmer
Oct 29, 2010
4
US
I am modifying a FoxPro 2.6 for Windows application where I need to prompt the user for selecting a file using the long file name scheme, instead of the 8.3 file name scheme. I would like to have the selected filename stored in a memory variable. Following is the code being used now:

* Allow user to select the filename/URL for attachment to add.
lcfilename = GETFILE("*","Select File","Select",0)

I'm guessing that using CALL32.DLL will be part of the solution, but I have never called any DLLs from within FoxPro.

Any guidance or code samples would be greatly appreciated.

Thanks,
Gene
 
Foxpro has no idea what long file names are, so even if you were to retrieve the long file name, FP wouldn't be able to work with it. It would still have to use the 8.3 filename.

That said, take a look at FOXTOOLS.FLL. You may be able to use that. The help file is posted on my website (link in my signature), scroll down to find 'TOOLHELP'.

You may also be able to use Windows Scripting Host to put the filename in a text file. You could then grab it out of the text file.



-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Hi Dave:

Thanks for the reply. I was actually reviewing your website when you replied. I have searched through Foxtools.fll on numerous occassions and can't seem to find any calls that are beneficial in solving this problem. I was hoping someone else had actually solved this problem already and could provide some sample code. I have a gut feeling it can be done because I can save to long file names when printing PDF files using the Adobe Writer print driver. I just don't know which DLL (WIN32.DLL or something else) out there that has the Open dialog function allowing long filenames. Hopefully someone can give me some nuggets of information.

Thanks again,
Gene
 
There are a couple posts in the FAQ's that may help you use foxtools to access the API calls - once you figure out what they are - but sorry. I don't have any more input for that.

One option, albeit a bit bulky, would be to write your own 'filer' type app. A "DIR" redirecting long and short file names to a text file, which you could import into a table.
You could then use that table to navigate using those file or directory names.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Thanks again Dave for your reply. After doing several searches and reading numerous blogs, I have concluded that the "GetOpenFileName" function within the Win32 API is the ultimate solution. I think the CALL32.dll library can be used to call the GetOpenFileName function within Win32. Now, I just need to figure out how to call that function within FoxPro 2.6 for Windows. Any words of wisdom from anyone that has done this before would be appreciated.

I feel like I am getting close. I will post the solution when I get it figure out.

Thanks again,
Gene
 
OK, I'm back. This has been one big pain in the rear. I've made a lot of progress on this issue, but one of the main problems is that there is VERY little sample code in FoxPro 2.6 in calling DLL files. Most of the code is in VFP, VB, or some other language that is already 32-bit or object oriented. Plus, Microsoft in its great wisdom, doesn't always provide the best documentation.

So, it appears the GETOPEFILENAME function is in the ComDlg32.DLL. As previously stated, there's no documentation on how to call this function from FP 2.6. It appears the best approach is to use the CALL32.DLL library to call the GETOPENFILE function. In addition, to call the CALL32.DLL library, you must use the FOXTOOLS.FLL library. So, following is the code I have come up with so far. All I need is the proper parameters for the GETOPENFILENAME function. Any help with this would be greatly appreciated.

CLEAR
SET LIBRARY TO FOXTOOLS

* Initialize variables.
lcfilename = "C:\TMG-TMS\DOC\Generated Settlement Statements 1.PDF"

* Initialize the "GETOPENFILENAME" function in the "ComDlg32.DLL" and return
* the 32-bit function handle. The ComDlg32.DLL is located in either the
* Windows\System or Windows\System32 directory.
lncall32 = REG32("GetOpenFileName","ComDlg32.DLL","")
@ 5,10 SAY "lncall32 variable: " + str(lncall32,10)

* Initialize a second function handle to be used by the CallFn function in
* FOXTOOLS.DLL. This will be the first parameter of the CallFn function.
lnfunchand = REGFP("C","C")
@ 10,10 SAY "lnfunchand: " + STR(lnfunchand,10)

* Call the GetOpenFileName function using the two file handles created
* previously.
lclongname = CALLFN(lnfunchand,lcfilename,lncall32)
@ 15,10 SAY "lclongname: " + lclongname

RELEASE LIBRARY FOXTOOLS

In the 3rd to the last line, the CALLFN is shutting down FP 2.6 for windows. I think it has to do with the middle parameter. I just don't know what the correct parameters are for the GETOPENFILENAME function. Does anyone know what the middle parameter value should be?

Thanks,
Gene
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top