Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 14311, SelectDirectory doesn't set selected directory on entry

by Rune Moberg Email: Anonymous


Suggested fix to Borland's SelectDirectory function (to allow you to specify default/current directory).
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 4.0  to 5.0 540 downloads
Copyright: No significant restrictions


Size: 959 bytes
Updated on Sat, 04 Nov 2000 08:01:53 GMT
Originally uploaded on Mon, 13 Mar 2000 00:00:00 GMT
SHA1 Hash: B23A44507347F13E352818A6E17602A8EBEFAD33
MD5 Hash: 285D643079A933E2B902C94F3CCEF5AC

    Explore the files in this upload

Description
Currently there are two SelectDirectory functions:

function SelectDirectory(const Caption: string; const Root: WideString; out Directory: string): Boolean; overload;
function SelectDirectory(var Directory: string; Options: TSelectDirOpts; HelpCtx: Longint): Boolean; overload;

The first uses a Windows Shell API function to display a small window allowing the user to select a directory. However, it doesn't allow the program to specify the currently selected directory, so it can be quite confusing for the end-user. Specifying a Root only makes it worse: It limits the range of choices, so if you specify 'D:\' as Root, only subdirectories residing under the 'D:' drive will be visible to the user!

The second option is Delphi's own implementation. Although more advanced, it will make your app look like a Windows 3.1 app with its old-style folder icons and such.

However, the third way is to rewrite Borland's wrapper code slightly and set up a callback that will be executed once Windows shows the selection window. To use this function simply pass a variable holding the currently selected directory. This variable will be set to point to the new directory upon exit:

sCurrentFolder := edtDirectory.Text;
if SelectDirectory('Select a folder', '', sCurrentFolder) then // old version used to ignore the content of sCurrentFolder
edtDirectory.Text := sCurrentFolder;

See attached file for SelectDirectory implementation details.

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03