Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1791
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: reading & writing a file
Next Topic: Restricting GridCtrl Selection to just One row
Goto Forum:
  


Current Time: Mon Jul 07 23:20:47 CEST 2025

Total time taken to generate the page: 0.03784 seconds