Home » Community » Newbie corner » using a file chooser (dir chooser??) to get a dir and not a file
Re: using a file chooser (dir chooser??) to get a dir and not a file [message #32752 is a reply to message #32749] |
Mon, 06 June 2011 08:17   |
|
The usage of ExecuteSelectDir() is very similar to ExecuteOpen(). Following code is taken from examples/CompDir, I just added few comments.
void DlgCompareDir::DoBrowse(Ctrl *field) // field is EditString or similar Ctrl
{
FileSel fsel;
fsel.AllFilesType();
static String recent_dir; // variable to store last opened directory
fsel <<= Nvl((String)~*field, recent_dir); //before opening, we pre-set the dialog to the value in field, fallback to recent_dir if there is Null
if(fsel.ExecuteSelectDir()) //open the dialog to select directory
*field <<= recent_dir = ~fsel; // assign the selected directory 'recent_dir' and also fill it into 'field' Ctrl
}
BTW: I just found there is even simpler way to do this, although not as versatile:String mydir = SelectDirectory();
Honza
|
|
|
Goto Forum:
Current Time: Mon Jul 07 23:20:47 CEST 2025
Total time taken to generate the page: 0.03784 seconds
|