April 12th, 2013, 11:18 AM
CFileDialog saves file in Project File, not Specified File
I'm very new to MFC & VisualC++. I'm using MSVS2010 Pro
I am trying to write/debug a simple form that saves and restores the content of some edit controls. It seems to work as expected, except the file saves only to the Project Folder, regardless of where I browse and select to save the file. I wonder if I'm missing a parameter and someone could help me?
(I hope this makes sense...)
My only experience is a little simple VB programming in Excel, so any specific examples would be much appreciated!
//Kinda Correct, Works but still saves in Project Folder
BOOL b_OpenFileDialog = FALSE; //this doesn't act as bool in CFileDialog?
LPCTSTR lpszDefExt = L"bcr";
LPCTSTR lpszFileName = L"Car_Description";
DWORD dwFlags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
LPCTSTR lpszFilter = L"BCR Files (*.bcr) |*.bcr|All Files (*.*)|*.*|";
LPCTSTR pParentWind = NULL;
int dwSize = 0;
int bVistaStyle = 1;
CFileDialog FileDlg( FALSE, lpszDefExt, lpszFileName, dwFlags, lpszFilter, NULL, dwSize, bVistaStyle);
if( FileDlg.DoModal() == IDOK )
//CString m_strPathname = FileDlg.GetPathName(); //This actually gets intended folder name
f.Open( FileDlg.GetFileName(), CFile::modeCreate | CFile::modeWrite);
CArchive ar(&f, CArchive::store); //This seems to be the save & restore cmd
ar << m_Make << m_Model << m_Year << m_Doors << m_Owner; //These are the edit controls we're saving/restoring
Also, rules seem to change from version to version? I have to "update" a number of undocumented programs. If anyone knows of any online tutorials I could read/follow along with that are somewhat up-to-date I would really appreciate it.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.