Bug in cGetFile()

Bug in cGetFile()

Postby Enrico Maria Giordano » 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: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

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

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in cGetFile()

Postby Antonio Linares » Tue Jan 31, 2017 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Re: Bug in cGetFile()

Postby Gale FORd » Fri Feb 17, 2017 7: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.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Bug in cGetFile()

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

Re: Bug in cGetFile()

Postby Antonio Linares » Tue Feb 21, 2017 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in cGetFile()

Postby Enrico Maria Giordano » Tue Feb 21, 2017 9: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
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in cGetFile()

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


Return to Bugs report & fixes / Informe de errores y arreglos

Who is online

Users browsing this forum: No registered users and 5 guests