Click to See Complete Forum and Search --> : CFileDialog
August 25th, 1999, 03:41 AM
Hi,
why is the following code not working? I get a debug assertion fault:
CFileDialog dlgLoad(TRUE);
dlgLoad.m_ofn.lpstrFilter = "HTML-Dateien\0*.htm;*.html";
dlgLoad.m_ofn.lpstrFile = "*.htm;*.html";
dlgLoad.m_ofn.lpstrInitialDir = "C:\\Eigene Dateien";
dlgLoad.m_ofn.Flags = OFN_HIDEREADONLY;
dlgLoad.DoModal();
If I remove the lines with Flags and lptstrFile, everything is fine.
Where's the problem?
TIA,
Fox20
Rail Jon Rogut
August 25th, 1999, 03:49 AM
Here's an example of what the call should look like:
void CYourDoc::OnFileOpen()
{
CString szTemp;
szTemp = AfxGetApp()->GetProfileString("Folders", "OpenDefault");
CFileDialog dlg(TRUE, _T("doc"), NULL,
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,
_T("Type of Files (*.doc;*.xls)|*.doc;*.xls|All Files (*.*)|*.*||"));
if (szTemp.GetLength() > 0)
dlg.m_ofn.lpstrInitialDir = (LPCTSTR)szTemp;
if (dlg.DoModal() != IDOK)
{
UpdateAllViews(NULL);
return; // stay with old data file
}
// Blah, Blah, Blah....
}
Rail
------------
Recording Engineer/Software Developer
Rail Jon Rogut Software
http://home.earthlink.net/~railro/
railro@earthlink.net
August 25th, 1999, 04:09 AM
Is it not possible to use it the way I did it?
Rail Jon Rogut
August 25th, 1999, 04:37 AM
With some changes... yes:
CFileDialog dlgLoad(TRUE);
// Change this slightly:
dlgLoad.m_ofn.lpstrFilter = _T("HTML-Dateien (*.htm;*.html)\0|*.htm;*.html\0\0");
dlgLoad.m_ofn.lpstrFile = _T("*.htm;*.html");
dlgLoad.m_ofn.lpstrInitialDir = _T(C:\\Eigene Dateien");
// You have to use a bitwise OR here:
dlgLoad.m_ofn.Flags |= OFN_HIDEREADONLY;
dlgLoad.DoModal();
Rail
------------
Recording Engineer/Software Developer
Rail Jon Rogut Software
http://home.earthlink.net/~railro/
railro@earthlink.net
August 25th, 1999, 04:42 AM
Ok, the bitwise OR makes sense, but the debug assertion is still there. Any other idea why?
TIA,
Fox20
Rail Jon Rogut
August 25th, 1999, 04:55 AM
No - other than the error in my code that I posted where I forgot to put a quote in the initial folder string, I tested this code on my system and it works perfectly.
Where are you making the call?
Rail
------------
Recording Engineer/Software Developer
Rail Jon Rogut Software
http://home.earthlink.net/~railro/
railro@earthlink.net
August 25th, 1999, 04:57 AM
well, thanks anyway
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.