CFileDialog - Multiple files selection
The other day I was creating a CFileOpen dialog with the multiple selection flag on (OFN_ALLOWMULTISELECT) and I forgot to set some parameters so today I have a mail with a new bug. The application couldn threw an error while trying to open multiple files because it didn't have space in the buffer to keep all the paths.
I was doing somo research in the msdn page and this is the solution:
I was doing somo research in the msdn page and this is the solution:
CFileDialog fileDialog(TRUE, NULL, NULL, dlgFlags, strFileFilter,pWndParent );CString fileName;fileDialog.GetOFN().lpstrFile = fileName.GetBuffer(MAX_FILES *(MAX_PATH + 1) + 1);fileDialog.GetOFN().nMaxFile = MAX_FILES *(MAX_PATH + 1) + 1;if ( fileDialog.DoModal() != IDOK )
You have to set a buffer with enough space to store the paths you are going to select before calling to DoModal() member function. It seems there isn't a way to change this after calling DoModel. It would be useful to have a flexible number of files...return;
Comentarios
Publicar un comentario