Jump to content
Sign in to follow this  
vitalstates

opendialog.initaldir

Recommended Posts

hello I'm returning to delphi after a bit of absense...still on XE5 and first post here as the developer network seems to have vanished...

 

this is an old chestnut and the search engines return loads of questions with no answers.

 

I cannot get the initaldir to work in open dialog.

I have resorted to hard coding exact locations, e.g c:\pathname\directory and even c:\

but nothing works, the opendialog always opens in mydocuments(win10 and win11)

 

does anybody have a view on this?

Share this post


Link to post

This is expected and even documented (see Windows7 item 1):

Quote

The initial directory. The algorithm for selecting the initial directory varies on different platforms.

Windows 7:

  1. 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.
  2. Otherwise, if lpstrFile contains a path, that path is the initial directory.
  3. Otherwise, if lpstrInitialDir is not NULL, it specifies the initial directory.
  4. If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.
  5. Otherwise, the initial directory is the personal files directory of the current user.
  6. Otherwise, the initial directory is the Desktop folder.

Windows 2000/XP/Vista:

  1. If lpstrFile contains a path, that path is the initial directory.
  2. Otherwise, lpstrInitialDir specifies the initial directory.
  3. 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.
  4. If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.
  5. Otherwise, the initial directory is the personal files directory of the current user.
  6. Otherwise, the initial directory is the Desktop folder.

 

  • Like 1

Share this post


Link to post

Thanks for the reply....I'm embarrased to say I've solved the problem...I had set initialdir after the opendialog.execute....

 

uber stupid on my part....it's a good job I've retired....

 

apologies and thanks for looking

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×