cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[SOLVED] Is there File chooser dialog class or method

Hi there

I would like to know is there a class or method to open file chooser dialog ?

Thanks in advance!
2 Replies 2
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Hi,

Yes, you can use DG::FileDialog for opening or saving files.
Here is an example code for you (copied from Communication_Manager example Add-On):
static bool	GetOpenFile (IO::Location*	dloc, const char* fileExtensions, const GS::UniString& filterText) 
{ 
	FTM::TypeID	retID; 
	FTM::FileTypeManager	ftman ("MyManager"); 
	FTM::FileType			type (NULL, fileExtensions, 0, 0, 0); 
	FTM::TypeID				id = FTM::FileTypeManager::SearchForType (type); 
	if (id == FTM::UnknownType) 
		id = ftman.AddType (type); 
 
	DG::FileDialog	dlg (DG::FileDialog::OpenFile);			// Open only 1 file 
	UIndex	i = dlg.AddFilter (id, DG::FileDialog::DisplayExtensions);	// Force it on mac... 
	dlg.SetFilterText (i, filterText); 
 
	if (dlg.Invoke ()) { 
		*dloc = dlg.GetSelectedFile (); 
		return (true); 
	} else 
		return (false); 
} 
 
// ----------------------------------------------------------------------------- 
 
// Using: 
	IO::Location dwgFileLoc; 
	if (!GetOpenFile (&dwgFileLoc, "dwg", "*.dwg")) 
		return; 
 
	IO::Name	dwgName; 
	dwgFileLoc.GetLastLocalName (&dwgName);

Note that the type of the FileDialog could be the followings: (see in DGFileDialog.hpp)
	enum Type { 
		OpenFile, 
		OpenMultiFile, 
		OpenFolder, 
		OpenMultiFolder, 
		Save 
	};

Regards,
Tibor
Anonymous
Not applicable
Hi.

Thank you for the quick response.

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!