Lets the user select a directory by displaying a dialog box.
Note: To add a description that contains Filectrl to the uses statement before use.
The function prototypes are as follows:
function selectdirectory (const caption:string; const root:widestring;
Out directory:string): Boolean; overload;
function Selectdirectory (var directory:string; options:tselectdiropts;
Helpctx:longint): Boolean; overload;
For the 1th overloaded function, the parameter caption is the caption of the dialog box, the parameter root specifies a directory for the initial directory to browse, and the selected directory is saved in the parameter directory.
For the 2nd overloaded function, the directory specified in the parameters directory is the directory selected when the dialog box is displayed, and the last user-selected directory is also saved in the parameter directory; The options are a collection of settings items, and if empty, the user can only select the existing directory through the dialog box. , no edit box is provided to the user to enter a new directory name. The tselectdiropts type is defined as follows:
Type
Tselectdiropt = (sdallowcreate, sdperformcreate, sdprompt);
Tselectdiropts = set of tselectdiropt;
The meanings of the specific values are as follows.
The sdallowcreate dialog box has an edit component that allows the user to enter a new directory name. But if you want to create a new directory, programmers must write their own code to create a new directory based on the obtained files.
The sdperformcreate dialog box has an edit component that allows the user to enter a directory name that does not exist, and the dialog box will select the directory and create it.
The sdprompt dialog box has an edit component that, if the user enters a directory name that does not exist, displays an informational dialog box that prompts you to create a new directory. If the Sdallowcreate setting is selected at the same time, the programmer must write the code to create a new directory based on the obtained file.
Usage:
Procedure Tform1.button1click (Sender:tobject);
Var
ss:string;
Begin
Selectdirectory (' Testdialog ', ' SSS ', Ss,[sdnewfolder, Sdshowedit, Sdshowshares, Sdnewui]);
End
Delphi Popup Selection dialog box Select Directory | selectdirectory function (GO)