Question about CFileDialog class
-
I have a dialog with two browse buttons on it. If i press the frist one, select a file than press the seccond one, my application crashes and i can't figure out why :( . Here's the code:
//first browse button
void CAddEquipDlg::OnBnClickedBrowsedb()
{
char szFilters[]=
"Access DB (*.mdb)|*.mdb|All Files (*.*)|*.*||";CFileDialog fDlg(TRUE, "mdb", "\*.mdb", OFN\_FILEMUSTEXIST| OFN\_HIDEREADONLY, szFilters, NULL ); if (fDlg.DoModal()==IDOK) { m\_sDB = fDlg.GetPathName(); } SetCurrentDirectory(m\_sCurDir); SetDlgItemText(IDC\_DB,m\_sDB); AfxGetApp()->WriteProfileString("Connection", "Database",m\_sDB);
}
//seccond browse button
void CAddEquipDlg::OnBnClickedBrowseequip()
{char szFilters\[\]= "CSV Files (\*.csv)|\*.csv|All Files (\*.\*)|\*.\*||"; CFileDialog fDlg(TRUE, "csv", "\*.csv", OFN\_FILEMUSTEXIST| OFN\_HIDEREADONLY, szFilters, NULL ); if (fDlg.DoModal()==IDOK) { CString bla = fDlg.GetFileTitle(); m\_sEQUIP = fDlg.GetPathName(); } SetCurrentDirectory(m\_sCurDir); SetDlgItemText(IDC\_EQUIP,m\_sEQUIP);
}
It crashes two out of tree times (with a send/don't send error message in release) and this is the debug info
First-chance exception at 0x7ca5159e in AddEquip.exe: 0xC0000005: Access violation reading location 0x62883720.
Unhandled exception at 0x7ca5159e in AddEquip.exe: 0xC0000005: Access violation reading location 0x62883720. -
I have a dialog with two browse buttons on it. If i press the frist one, select a file than press the seccond one, my application crashes and i can't figure out why :( . Here's the code:
//first browse button
void CAddEquipDlg::OnBnClickedBrowsedb()
{
char szFilters[]=
"Access DB (*.mdb)|*.mdb|All Files (*.*)|*.*||";CFileDialog fDlg(TRUE, "mdb", "\*.mdb", OFN\_FILEMUSTEXIST| OFN\_HIDEREADONLY, szFilters, NULL ); if (fDlg.DoModal()==IDOK) { m\_sDB = fDlg.GetPathName(); } SetCurrentDirectory(m\_sCurDir); SetDlgItemText(IDC\_DB,m\_sDB); AfxGetApp()->WriteProfileString("Connection", "Database",m\_sDB);
}
//seccond browse button
void CAddEquipDlg::OnBnClickedBrowseequip()
{char szFilters\[\]= "CSV Files (\*.csv)|\*.csv|All Files (\*.\*)|\*.\*||"; CFileDialog fDlg(TRUE, "csv", "\*.csv", OFN\_FILEMUSTEXIST| OFN\_HIDEREADONLY, szFilters, NULL ); if (fDlg.DoModal()==IDOK) { CString bla = fDlg.GetFileTitle(); m\_sEQUIP = fDlg.GetPathName(); } SetCurrentDirectory(m\_sCurDir); SetDlgItemText(IDC\_EQUIP,m\_sEQUIP);
}
It crashes two out of tree times (with a send/don't send error message in release) and this is the debug info
First-chance exception at 0x7ca5159e in AddEquip.exe: 0xC0000005: Access violation reading location 0x62883720.
Unhandled exception at 0x7ca5159e in AddEquip.exe: 0xC0000005: Access violation reading location 0x62883720.At what line it takes you in the code ? if you try to debug crash .
Prasad Notifier using ATL | Operator new[],delete[][^]
-
I have a dialog with two browse buttons on it. If i press the frist one, select a file than press the seccond one, my application crashes and i can't figure out why :( . Here's the code:
//first browse button
void CAddEquipDlg::OnBnClickedBrowsedb()
{
char szFilters[]=
"Access DB (*.mdb)|*.mdb|All Files (*.*)|*.*||";CFileDialog fDlg(TRUE, "mdb", "\*.mdb", OFN\_FILEMUSTEXIST| OFN\_HIDEREADONLY, szFilters, NULL ); if (fDlg.DoModal()==IDOK) { m\_sDB = fDlg.GetPathName(); } SetCurrentDirectory(m\_sCurDir); SetDlgItemText(IDC\_DB,m\_sDB); AfxGetApp()->WriteProfileString("Connection", "Database",m\_sDB);
}
//seccond browse button
void CAddEquipDlg::OnBnClickedBrowseequip()
{char szFilters\[\]= "CSV Files (\*.csv)|\*.csv|All Files (\*.\*)|\*.\*||"; CFileDialog fDlg(TRUE, "csv", "\*.csv", OFN\_FILEMUSTEXIST| OFN\_HIDEREADONLY, szFilters, NULL ); if (fDlg.DoModal()==IDOK) { CString bla = fDlg.GetFileTitle(); m\_sEQUIP = fDlg.GetPathName(); } SetCurrentDirectory(m\_sCurDir); SetDlgItemText(IDC\_EQUIP,m\_sEQUIP);
}
It crashes two out of tree times (with a send/don't send error message in release) and this is the debug info
First-chance exception at 0x7ca5159e in AddEquip.exe: 0xC0000005: Access violation reading location 0x62883720.
Unhandled exception at 0x7ca5159e in AddEquip.exe: 0xC0000005: Access violation reading location 0x62883720.It's difficult to see the problem. What you can do to narrow the problem is use your debugger (press F5) to see where in your code the crash occurs. Then you can watch for the different variables and check if everything is correct. You can also set breakpoint (press F9) before the crash to see the evolution of the variables.
Cédric Moonen Software developer
Charting control [v1.1] -
I have a dialog with two browse buttons on it. If i press the frist one, select a file than press the seccond one, my application crashes and i can't figure out why :( . Here's the code:
//first browse button
void CAddEquipDlg::OnBnClickedBrowsedb()
{
char szFilters[]=
"Access DB (*.mdb)|*.mdb|All Files (*.*)|*.*||";CFileDialog fDlg(TRUE, "mdb", "\*.mdb", OFN\_FILEMUSTEXIST| OFN\_HIDEREADONLY, szFilters, NULL ); if (fDlg.DoModal()==IDOK) { m\_sDB = fDlg.GetPathName(); } SetCurrentDirectory(m\_sCurDir); SetDlgItemText(IDC\_DB,m\_sDB); AfxGetApp()->WriteProfileString("Connection", "Database",m\_sDB);
}
//seccond browse button
void CAddEquipDlg::OnBnClickedBrowseequip()
{char szFilters\[\]= "CSV Files (\*.csv)|\*.csv|All Files (\*.\*)|\*.\*||"; CFileDialog fDlg(TRUE, "csv", "\*.csv", OFN\_FILEMUSTEXIST| OFN\_HIDEREADONLY, szFilters, NULL ); if (fDlg.DoModal()==IDOK) { CString bla = fDlg.GetFileTitle(); m\_sEQUIP = fDlg.GetPathName(); } SetCurrentDirectory(m\_sCurDir); SetDlgItemText(IDC\_EQUIP,m\_sEQUIP);
}
It crashes two out of tree times (with a send/don't send error message in release) and this is the debug info
First-chance exception at 0x7ca5159e in AddEquip.exe: 0xC0000005: Access violation reading location 0x62883720.
Unhandled exception at 0x7ca5159e in AddEquip.exe: 0xC0000005: Access violation reading location 0x62883720.Did you try debugging? Where exactly is the app crashing?
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
-
Did you try debugging? Where exactly is the app crashing?
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
-
The debugger does not take me to any line in my code. It crashes after the second filedialog has been displayed and all i get is a "Show disasembly" option which does nothing:(
How can that happen! I hope you have set break points. Have you?
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
-
How can that happen! I hope you have set break points. Have you?
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
-
where do you want me to set brakepoints? i've set them for every line in my code but the application dies while browsing for the file (ie: CFileDialog::DoModal() never returns)
What does the call stack look like? Is there any line that points to code for which you have source code? I assume you have built your application for debug...:~ -- Rog
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"No one remembers a coward!" - Jan Elfström 1998
"...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above -
where do you want me to set brakepoints? i've set them for every line in my code but the application dies while browsing for the file (ie: CFileDialog::DoModal() never returns)
When you come to Domodal set a breakpoint after it
WhiteSky
-
When you come to Domodal set a breakpoint after it
WhiteSky
-
What does the call stack look like? Is there any line that points to code for which you have source code? I assume you have built your application for debug...:~ -- Rog
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"No one remembers a coward!" - Jan Elfström 1998
"...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above -
...it dies during CFileDialog::DoModal() method (i mean, it dies while my dialog waits for CFileDialog::DoModal() to return)
7CA5159E call dword ptr [ecx+14h]
That's the disassembly code, but i don't know what to do with it, i don't think it helps
Did you try displaying a message box before and after your CFileDialog creation? What happens in that case?
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
-
I have a dialog with two browse buttons on it. If i press the frist one, select a file than press the seccond one, my application crashes and i can't figure out why :( . Here's the code:
//first browse button
void CAddEquipDlg::OnBnClickedBrowsedb()
{
char szFilters[]=
"Access DB (*.mdb)|*.mdb|All Files (*.*)|*.*||";CFileDialog fDlg(TRUE, "mdb", "\*.mdb", OFN\_FILEMUSTEXIST| OFN\_HIDEREADONLY, szFilters, NULL ); if (fDlg.DoModal()==IDOK) { m\_sDB = fDlg.GetPathName(); } SetCurrentDirectory(m\_sCurDir); SetDlgItemText(IDC\_DB,m\_sDB); AfxGetApp()->WriteProfileString("Connection", "Database",m\_sDB);
}
//seccond browse button
void CAddEquipDlg::OnBnClickedBrowseequip()
{char szFilters\[\]= "CSV Files (\*.csv)|\*.csv|All Files (\*.\*)|\*.\*||"; CFileDialog fDlg(TRUE, "csv", "\*.csv", OFN\_FILEMUSTEXIST| OFN\_HIDEREADONLY, szFilters, NULL ); if (fDlg.DoModal()==IDOK) { CString bla = fDlg.GetFileTitle(); m\_sEQUIP = fDlg.GetPathName(); } SetCurrentDirectory(m\_sCurDir); SetDlgItemText(IDC\_EQUIP,m\_sEQUIP);
}
It crashes two out of tree times (with a send/don't send error message in release) and this is the debug info
First-chance exception at 0x7ca5159e in AddEquip.exe: 0xC0000005: Access violation reading location 0x62883720.
Unhandled exception at 0x7ca5159e in AddEquip.exe: 0xC0000005: Access violation reading location 0x62883720.eusto wrote:
If i press the frist one, select a file than press the seccond one, my application crashes...
What happens if you reverse this process? Which of the four statements after
DoModal()
is crashing? Set a breakpoint to find out.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Did you try displaying a message box before and after your CFileDialog creation? What happens in that case?
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
-
eusto wrote:
If i press the frist one, select a file than press the seccond one, my application crashes...
What happens if you reverse this process? Which of the four statements after
DoModal()
is crashing? Set a breakpoint to find out.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
None of the four statements after DoModal() is crashing!..none! DoModal() doesn't even return. Anyways, i've narrowed it down. It crashes when i move trough folders in the CFileDialog window. And it doesn't really matter wich of the two buttons i press first.
-
None of the four statements after DoModal() is crashing!..none! DoModal() doesn't even return. Anyways, i've narrowed it down. It crashes when i move trough folders in the CFileDialog window. And it doesn't really matter wich of the two buttons i press first.
This is just a complete guess, but how about commenting out everything after the
DoModal()
call?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
This is just a complete guess, but how about commenting out everything after the
DoModal()
call?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
this was my last resort too but it still failed :(. I'm putting this thing to rest and i'll get to it some other time... Maybe there's a problem with my computer( a virus or smth...don't know ). The problem is clearly in the CFileDialog class but i can't figure it out.
-
this was my last resort too but it still failed :(. I'm putting this thing to rest and i'll get to it some other time... Maybe there's a problem with my computer( a virus or smth...don't know ). The problem is clearly in the CFileDialog class but i can't figure it out.
eusto wrote:
The problem is clearly in the CFileDialog class...
To further verify that, use
GetOpenFileName()
instead.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
eusto wrote:
The problem is clearly in the CFileDialog class...
To further verify that, use
GetOpenFileName()
instead.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
eusto wrote:
The problem is clearly in the CFileDialog class...
To further verify that, use
GetOpenFileName()
instead.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb