I am writing an MFC application that is dialog-based in Visual C++ (Visual Studio 2012). The dialog has a menu on the top containing an entry to open a file.
When the CFileDialog::DoModal( ) method is called the dialog window (including menu, red 'X' button on top-right) gets gray (which is normal behavior). However, it still is gray when the file dialog is closed.
This is still true when I do not select a file an click 'Cancel' in the file dialog.
Here the code being called when 'File open' is clicked in the menu:
CFileDialog fileDialog( TRUE, NULL, NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, _T( "AProsteriori-Files (*.apr)|*.apr|All Files (*.*)|*.*||" ), this );
fileDialog.m_ofn.lpstrTitle = _T( "Open AProsteriori-file" );
if (fileDialog.DoModal() == IDOK)
CString strPath = fileDialog.GetPathName();
if ( strPath.Find( _T( ":\\\\" ) ) == 1 && strPath.GetLength( ) > 4 )
// this means we have an invalid path that looks like this:
// get rid of extra slash
temp = strPath.Left( 3 );
temp += strPath.Mid( 4 );
strPath = temp;
// Let's get it ...
theFile.Open( strPath, CFile::modeRead );
CArchive archive( &theFile, CArchive::load );
Serialize( archive );
Any help is welcome.