FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Bugs report & fixes / Informe de errores y arreglos Bug in cGetFile()
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Bug in cGetFile()
Posted: Mon Jan 30, 2017 10:11 AM
In the following sample, if you select a file in another directory, the next time you run the sample, the other directory is shown instead of the current directory.

Any workaround?

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    CGETFILE( "All files (*.*)|*.*", "Select a file", , CURDRIVE() + ":\" + CURDIR() )

    RETURN NIL


EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in cGetFile()
Posted: Tue Jan 31, 2017 09:23 AM
Enrico,

We are using the flag OFN_NOCHANGEDIR:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646839(v=vs.85).aspx

Restores the current directory to its original value if the user changed the directory while searching for files.
This flag is ineffective for GetOpenFileName


so it seems as it is a GetOpenFileName() bug
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Bug in cGetFile()
Posted: Fri Feb 17, 2017 07:05 PM

Is there any fix for this? I want a certain default directory but I can't rely on it.
I created an Outlook signature program and I expect it to default to the correct user profile area. If user changes drive/folder then the next time the user cannot updated or add signature correctly.
Try telling user to change c:\Users+[ProfileName]+\AppData\Roaming\Microsoft\Signatures\ if Windows 7 or c:\Users+[ProfileName]+\Application Data\Microsoft\Signatures\ if Windows 8/10.

Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Bug in cGetFile()
Posted: Fri Feb 17, 2017 10:08 PM
I followed the link to openfilename in msdn and I read that OFN_NOCHANGEDIR does not work for GetOpenFIlename see quote below.
Is there another way?

Restores the current directory to its original value if the user changed the directory while searching for files.

This flag is ineffective for GetOpenFileName.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in cGetFile()
Posted: Tue Feb 21, 2017 07:23 AM

A possible solution is to save the current directory using GetCurDir() before calling cGetFile() and restore it later using SetCurDir()

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in cGetFile()
Posted: Tue Feb 21, 2017 09:31 AM

This would not solve the problem. cGetFile() would continue to show the changed directory. Is not the current directory of the application that changes, is the directory shown by cGetFile().

Anyway, I just tried your suggestion and it doesn't work.

EMG

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in cGetFile()
Posted: Tue Feb 21, 2017 12:10 PM

I saw the solution googling for info about it but I had not tried it, so many thanks Enrico for your feedback

Stackoverflow seems the right way to look into for a possible solution

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion