lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] wxmsw-2.9 regression: default directory for File | Open


From: Vadim Zeitlin
Subject: Re: [lmi] wxmsw-2.9 regression: default directory for File | Open
Date: Sat, 28 Mar 2009 00:30:04 +0100

On Tue, 24 Mar 2009 14:17:20 +0000 Greg Chicares <address@hidden> wrote:

GC> To reproduce:
GC>   load lmi on msw [FWIW, I'm using msw 'xp']
GC>   File | Open
GC> Examine the "Look in:" directory shown at the top of the dialog.
GC> 
GC> With wx-2.8.10 and prior versions, this apparently is set to the
GC> directory of the first file in the history list saved in HKCU/lmi.

 This is not quite true, there was no code to save (nor to restore) the
last file dialog directory into the registry in 2.8 neither. What happened
in 2.8 was that we always used the empty directory in the file dialog and
so Windows was picking the last used one itself (at least in XP this is
done using the data under HKCU\Software\Microsoft\Windows\CurrentVersion\
Explorer\ComDlg32\LastVisitedMRU: MRUList there contains the last used
directories, in order, and each entry contains the name of the program
followed by the name of directory to be used for it after a NUL).

GC> That's a useful behavior: the directory that users are most likely
GC> to want is the last directory they used in a prior session.

 But the above doesn't change the fact that this indeed was a useful
feature. The problem with it was that it didn't make a good choice of the
initial directory the very first time a program was run: if there is no
entry in MRU list, the current directory (which is typically the directory
containing the program) is used. And in most cases "My Documents" is a
better choice for the initial directory.

 The problem is that there is no obvious way to get the best of both worlds
because there is no simple way to know if an entry for our program is
present in Windows MRU list or not. We could try parsing the data under the
registry key mentioned above but this would be XP-specific (it changed in
Vista and might change again in Windows 7 and I'm almost sure it wasn't
done like this in some old Windows versions neither) and so doesn't seem
like the right thing to do.

 I can think of 2 general solutions. First one is to always keep track of
the last used directory at the application level. I.e. in LMI case it
should save wxDocManager::GetLastDirectory() on application exit and
restore it using SetLastDirectory() on next run. This should work perfectly
well but does require some effort (albeit not much).

 Second solution would be to make wx a bit smarter with its auto
determination of the last directory and use the most recent file in
wxFileHistory and only fall back to "My Documents" if the history is empty.
This seems a bit more fragile but still should typically work very well. So
if you don't see any objections to it, I'll implement this behaviour in wx
itself.

 Thanks,
VZ

reply via email to

[Prev in Thread] Current Thread [Next in Thread]