Error using GetOpenFileName in debug version, and not in release
C / C++ / MFC
2
Posts
1
Posters
0
Views
1
Watching
-
Im trying this code in a dialog with only a button when you push it this code is executed:
void CBorradlgDlg::OnButton1() { // TODO: Add your control notification handler code here OPENFILENAME ofn; // common dialog box structure char szFile[512]; // buffer for file name char title[]="Title openfilename"; // Initialize OPENFILENAME //ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = GetSafeHwnd(); ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFilter = "Object\0*.obj\0All\0*.*\0Text\0*.TXT\0"; ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; ofn.hInstance=0; ofn.lpstrCustomFilter=NULL; ofn.nMaxCustFilter=0; ofn.lpstrTitle=(LPSTR)title; ofn.nFileOffset=0; ofn.nFileExtension=0; ofn.lpstrDefExt=".obj"; ofn.lCustData=0L; ofn.lpfnHook=NULL; ofn.lpTemplateName=NULL; // Display the Open dialog box. if(GetOpenFileName( &ofn ) != TRUE) { DWORD Errval=CommDlgExtendedError(); switch(Errval) { case CDERR_DIALOGFAILURE: AfxMessageBox("CDERR_DIALOGFAILURE "); break; case CDERR_FINDRESFAILURE: AfxMessageBox("CDERR_FINDRESFAILURE "); break; case CDERR_NOHINSTANCE: AfxMessageBox("CDERR_NOHINSTANCE "); break; case CDERR_INITIALIZATION: AfxMessageBox("CDERR_INITIALIZATION "); break; case CDERR_NOHOOK :AfxMessageBox("CDERR_NOHOOK "); break; case CDERR_LOCKRESFAILURE: AfxMessageBox("CDERR_LOCKRESFAILURE "); break; case CDERR_NOTEMPLATE: AfxMessageBox("CDERR_NOTEMPLATE "); break; case CDERR_LOADRESFAILURE: AfxMessageBox("CDERR_LOADRESFAILURE "); break; case CDERR_STRUCTSIZE: AfxMessageBox("CDERR_STRUCTSIZE "); break; case CDERR_LOADSTRFAILURE: AfxMessageBox("CDERR_LOADSTRFAILURE "); break; case FNERR_BUFFERTOOSMALL: AfxMessageBox("FNERR_BUFFERTOOSMALL "); break; case CDERR_MEMALLOCFAILURE: AfxMessageBox("CDERR_MEMALLOCFAILURE "); break; case FNERR_INVALIDFILENAME: AfxMessageBox("FNERR_INVALIDFILENAME "); break; case CDERR_MEMLOCKFAILURE: AfxMessageBox("CDERR_MEMLOCKFAILURE "); break; case FNERR_SUBCLASSFAILURE:AfxMessageBox("FNERR_SUBCLASSFAILURE "); break; } } }
Debug version throws CDERR_INITIALIZATION error :confused: Release version works fine :) where is the error? Im using XP VC6 SP5 Thanks.
-
Im trying this code in a dialog with only a button when you push it this code is executed:
void CBorradlgDlg::OnButton1() { // TODO: Add your control notification handler code here OPENFILENAME ofn; // common dialog box structure char szFile[512]; // buffer for file name char title[]="Title openfilename"; // Initialize OPENFILENAME //ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = GetSafeHwnd(); ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFilter = "Object\0*.obj\0All\0*.*\0Text\0*.TXT\0"; ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; ofn.hInstance=0; ofn.lpstrCustomFilter=NULL; ofn.nMaxCustFilter=0; ofn.lpstrTitle=(LPSTR)title; ofn.nFileOffset=0; ofn.nFileExtension=0; ofn.lpstrDefExt=".obj"; ofn.lCustData=0L; ofn.lpfnHook=NULL; ofn.lpTemplateName=NULL; // Display the Open dialog box. if(GetOpenFileName( &ofn ) != TRUE) { DWORD Errval=CommDlgExtendedError(); switch(Errval) { case CDERR_DIALOGFAILURE: AfxMessageBox("CDERR_DIALOGFAILURE "); break; case CDERR_FINDRESFAILURE: AfxMessageBox("CDERR_FINDRESFAILURE "); break; case CDERR_NOHINSTANCE: AfxMessageBox("CDERR_NOHINSTANCE "); break; case CDERR_INITIALIZATION: AfxMessageBox("CDERR_INITIALIZATION "); break; case CDERR_NOHOOK :AfxMessageBox("CDERR_NOHOOK "); break; case CDERR_LOCKRESFAILURE: AfxMessageBox("CDERR_LOCKRESFAILURE "); break; case CDERR_NOTEMPLATE: AfxMessageBox("CDERR_NOTEMPLATE "); break; case CDERR_LOADRESFAILURE: AfxMessageBox("CDERR_LOADRESFAILURE "); break; case CDERR_STRUCTSIZE: AfxMessageBox("CDERR_STRUCTSIZE "); break; case CDERR_LOADSTRFAILURE: AfxMessageBox("CDERR_LOADSTRFAILURE "); break; case FNERR_BUFFERTOOSMALL: AfxMessageBox("FNERR_BUFFERTOOSMALL "); break; case CDERR_MEMALLOCFAILURE: AfxMessageBox("CDERR_MEMALLOCFAILURE "); break; case FNERR_INVALIDFILENAME: AfxMessageBox("FNERR_INVALIDFILENAME "); break; case CDERR_MEMLOCKFAILURE: AfxMessageBox("CDERR_MEMLOCKFAILURE "); break; case FNERR_SUBCLASSFAILURE:AfxMessageBox("FNERR_SUBCLASSFAILURE "); break; } } }
Debug version throws CDERR_INITIALIZATION error :confused: Release version works fine :) where is the error? Im using XP VC6 SP5 Thanks.