Home Delphi 7 Windows 7 Can't set active direcory, when a dpr file is opened from windows explorer

# Delphi 7 Windows 7 Can't set active direcory, when a dpr file is opened from windows explorer

Lim IG
1#
Lim IG Published in 2017-09-11 10:43:02Z
 I used to open Delphi 7 dpr files from windows explorer. Delphi used to update current save directory. But from windows 7 and on this doesnt work. I open dpr from windows explorer, add a new form. When I try to save new unit, delphi tries to save file to last known directory. Is there a solution to this problem?
Remy Lebeau
2#
Remy Lebeau Reply to 2017-09-11 15:23:33Z
 Delphi 7 uses the older Common Dialog Box API for opening/saving files (GetOpenFileName() and GetSaveFileName() functions). That API was replaced with the newer Common Item Dialog API (IFileOpenDialog and IFileSaveDialog interfaces) in Vista. The behavior you describe is simply how the old API works in modern Windows versions. Per the OPENFILENAME structure documentation: lpstrInitialDir Type: LPCTSTR The initial directory. The algorithm for selecting the initial directory varies on different platforms. Windows 7: If lpstrInitialDir has the same value as was passed the first time the application used an Open or Save As dialog box, the path most recently selected by the user is used as the initial directory. Otherwise, if lpstrFile contains a path, that path is the initial directory. Otherwise, if lpstrInitialDir is not NULL, it specifies the initial directory. If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory. Otherwise, the initial directory is the personal files directory of the current user. Otherwise, the initial directory is the Desktop folder. Windows 2000/XP/Vista: If lpstrFile contains a path, that path is the initial directory. Otherwise, lpstrInitialDir specifies the initial directory. Otherwise, if the application has used an Open or Save As dialog box in the past, the path most recently used is selected as the initial directory. However, if an application is not run for a long time, its saved selected path is discarded. If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory. Otherwise, the initial directory is the personal files directory of the current user. Otherwise, the initial directory is the Desktop folder.
 You need to login account before you can post.
Processed in 0.341003 second(s) , Gzip On .