I have overridden OnFileSave and used CFileDialog to implement the process. It would be useful if the dialog would warn the user if a file of that name already exists, offering an option to replace it. But my overridden implementation doesnt do that. It will simply overwrite the file if it exists. (very unprofessional).
Is there a flag or something that can be set using CFileDialog that will warn if file exists?
Here's the code I've been using:
Code:void myDlg::OnFileSaveas() { const char fileDialogFilter[] = "Data Files (*.dat)|*.dat||"; const char fileDialogExt[] = "dat"; CFileDialog fileDialog(FALSE, fileDialogExt, m_csFilename, OFN_FILEMUSTEXIST, fileDialogFilter); if (fileDialog.DoModal() == IDOK) { CWaitCursor wait; if(fileDialog.GetFileExt()=="dat") { m_csPathname = fileDialog.GetPathName(); m_csFilename = fileDialog.GetFileName(); //.. do the save } } }




Reply With Quote