Page 1 of 1

Bug in cGetFile()

PostPosted: Mon Jan 30, 2017 10:11 am
by Enrico Maria Giordano
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: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

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

    RETURN NIL


EMG

Re: Bug in cGetFile()

PostPosted: Tue Jan 31, 2017 9:23 am
by Antonio Linares
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

Re: Bug in cGetFile()

PostPosted: Tue Jan 31, 2017 10:04 am
by Enrico Maria Giordano
Most likely.

EMG

Re: Bug in cGetFile()

PostPosted: Fri Feb 17, 2017 7:05 pm
by Gale FORd
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.

Re: Bug in cGetFile()

PostPosted: Fri Feb 17, 2017 10:08 pm
by Gale FORd
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.

Re: Bug in cGetFile()

PostPosted: Tue Feb 21, 2017 7:23 am
by Antonio Linares
A possible solution is to save the current directory using GetCurDir() before calling cGetFile() and restore it later using SetCurDir()

Re: Bug in cGetFile()

PostPosted: Tue Feb 21, 2017 9:31 am
by Enrico Maria Giordano
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

Re: Bug in cGetFile()

PostPosted: Tue Feb 21, 2017 12:10 pm
by Antonio Linares
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