HI all,
I'm having some trouble figuring out how to do this one.
Assimp gives me a string, containing all the file extensions it can handle.
I found some code to tokenize strings on SO and wrapped it in a function.
The format of the string that is used to initialise the accepted extensions list for the OPENFILENAME structure is as follows:
L"All\0*.*\0Text\*.txt\0"
And so I'm trying to recreate that programatically. Which is a nightmare, as I'm trying to stick '\0' in the middle of a string.
// Get a vector of extensions supported by Assimp ( assimp exts string, tokenise by ';' )
std::vector<std::string> exts = Scatterbrain::Split(extsAccepted.c_str(), ';');
//create a string with a bunch of '\0' s in it, if possible
std::string extsList="";
for(size_t i = 0; i < exts.size(); i++)
extsList.append(exts[i] + '\0');
// contains the first extension.
CString pwszExts(extsList.c_str());
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
ofn.lpstrFilter = (LPCWSTR)pwszExts; // This one
...
// Display the Open dialog box.
if( GetOpenFileName(&ofn) == TRUE )
{
...
Okay - I see one bug already: the dialog is going to say 'extension_a extension_b', instead of 'ext_name_a ext_a', but I'm happy to add blank spaces for names.
how is the generation of a string
L"Hello\0World\0How\0Are\0You\0'
done?
Thanks in advance