Preselecting files in a CFileDialog
Just wondering how and if you can pre-select multiple files as the dialog opens? Do you place a list of them in the Initial Filename area, as I've tried this already the answer seems to be, No.
Am I missing something?
Basically I'd like a user to be able to select multiple files, I then do some checking of the filenames and if one of these checks comes back false, I want to reload this dialog with the files that the user had previously selected.
Any help would be greatly appreciated
CFileDialog dlg(FALSE/*Open=TRUE Save=False*/,NULL/*Filename Extension*/,""/*Initial Filename*/,OFN_ENABLESIZING|OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT/*Flags*/,"All Files(*.*)|*.*||"/*Filetype Filter*/);
const int nBufferSize = 128*1024; // May be excessive?
TCHAR *szNewBuffer = new TCHAR[nBufferSize];
memset(szNewBuffer, 0, sizeof(TCHAR) * nBufferSize);
dlg.m_ofn.lpstrFile = szNewBuffer;
dlg.m_ofn.nMaxFile = nBufferSize - 1;
if (dlg.DoModal() == IDOK)
POSITION pos = dlg.GetStartPosition();
filePaths = "";
fileNameList = "";
fullpath = dlg.GetNextPathName(pos);
nLastSlashPos = fullpath.ReverseFind('\\');
if(nLastSlashPos >= 0)
filename = fullpath.Mid(nLastSlashPos+1);
if (filePaths != "")
filePaths = filePaths + "|";
fileNameList = fileNameList + " ";
filePaths = filePaths + fullpath;
fileNameList = fileNameList + '"' + filename + '"';