Bug in cGetFile()

Post Reply
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Bug in cGetFile()

Post 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

#include "Fivewin.ch"


FUNCTION MAIN()

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

    RETURN NIL
EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in cGetFile()

Post by Antonio Linares »

Enrico,

We are using the flag OFN_NOCHANGEDIR:

https://msdn.microsoft.com/en-us/librar ... s.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
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Re: Bug in cGetFile()

Post 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.
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Re: Bug in cGetFile()

Post 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.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in cGetFile()

Post by Antonio Linares »

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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in cGetFile()

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in cGetFile()

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply