EDN Admin
Well-known member
I am working on old VC++ code that could not be imported to newer VS. It had file inclusions like "Gui/FileDlg.h" and "Gui/FolderDlg.h.
and was using the following piece of code to access those modules :
Gui::FileDlg fileDlg(
TRUE,
System:ath::String(),
System:ath(),
OFN_CREATEPROMPT | OFN_ENABLESIZING,
_T("Log Files (*.dlf;*.isf)|*.dlf;*.isf|All Files (*.*)|*.*||"),
NULL
);
// Initializes m_ofn structure and sets title
fileDlg.setTitle(_T("Select input file"));
// Call DoModal
if (IDOK == fileDlg.doModal())
{
inputFileName = fileDlg.getPathName().toString().c_str();
}
I see that there is nothing like a FileDlg class in VS and there is something called as CFileDialog in MFC.
I replaced the existing code with :
CFileDialog dlg(TRUE);
dlg.m_ofn.nMaxFile = 511;
dlg.m_ofn.lpstrFilter="XML Files (*.xml)*.xmlText Files (*.txt)*.txtAll Files (*.*)*.*";
dlg.m_ofn.lpstrTitle="Save XML File As";
CString filename;
if(dlg.DoModal() == IDOK)
{
inputFileName = dlg.GetPathName(); // return full path and filename
}
and included #include "stdafx.h"
The Stdafx.h was created when I created a sample MFC application in VS2008. I copied the header file over to this project.
This is now erroring out at "ASSERT(afxCurrentResourceHandle != NULL)"
I have added AFX_MANAGE_STATE(AfxGetStaticModuleState()); at the very beginning of the code according to suggestions for similar error online. I am still unable to proceed.
1 more piece of info : when I copy pasted the CFileDialog code in the sample MFC application, that errors at CallWindowProc(oldWndProc, hWnd, nMsg, wParam, lParam) , in AfxWindowActivationWndProc.h
Thank you
View the full article
and was using the following piece of code to access those modules :
Gui::FileDlg fileDlg(
TRUE,
System:ath::String(),
System:ath(),
OFN_CREATEPROMPT | OFN_ENABLESIZING,
_T("Log Files (*.dlf;*.isf)|*.dlf;*.isf|All Files (*.*)|*.*||"),
NULL
);
// Initializes m_ofn structure and sets title
fileDlg.setTitle(_T("Select input file"));
// Call DoModal
if (IDOK == fileDlg.doModal())
{
inputFileName = fileDlg.getPathName().toString().c_str();
}
I see that there is nothing like a FileDlg class in VS and there is something called as CFileDialog in MFC.
I replaced the existing code with :
CFileDialog dlg(TRUE);
dlg.m_ofn.nMaxFile = 511;
dlg.m_ofn.lpstrFilter="XML Files (*.xml)*.xmlText Files (*.txt)*.txtAll Files (*.*)*.*";
dlg.m_ofn.lpstrTitle="Save XML File As";
CString filename;
if(dlg.DoModal() == IDOK)
{
inputFileName = dlg.GetPathName(); // return full path and filename
}
and included #include "stdafx.h"
The Stdafx.h was created when I created a sample MFC application in VS2008. I copied the header file over to this project.
This is now erroring out at "ASSERT(afxCurrentResourceHandle != NULL)"
I have added AFX_MANAGE_STATE(AfxGetStaticModuleState()); at the very beginning of the code according to suggestions for similar error online. I am still unable to proceed.
1 more piece of info : when I copy pasted the CFileDialog code in the sample MFC application, that errors at CallWindowProc(oldWndProc, hWnd, nMsg, wParam, lParam) , in AfxWindowActivationWndProc.h
Thank you
View the full article