Click here to Skip to main content
15,907,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How do i activate different child frames? Pin
Mark Salsbery27-Oct-06 6:28
Mark Salsbery27-Oct-06 6:28 
QuestionMonitoring/manipulating Packet traffic. Pin
Kobi_Z26-Oct-06 23:02
Kobi_Z26-Oct-06 23:02 
AnswerRe: Monitoring/manipulating Packet traffic. Pin
dzolee27-Oct-06 1:50
dzolee27-Oct-06 1:50 
QuestionHow to create multiple workspaces for a single project? Pin
swati.ghadage26-Oct-06 22:55
swati.ghadage26-Oct-06 22:55 
AnswerRe: How to create multiple workspaces for a single project? Pin
Sceptic Mole26-Oct-06 23:35
Sceptic Mole26-Oct-06 23:35 
QuestionMSVC++ Enterprise version Vs Standard version Pin
koumodaki26-Oct-06 22:52
koumodaki26-Oct-06 22:52 
AnswerRe: MSVC++ Enterprise version Vs Standard version Pin
David Crow27-Oct-06 4:16
David Crow27-Oct-06 4:16 
QuestionProblem with CFileDialog (access violation). Pin
kiranin26-Oct-06 22:42
kiranin26-Oct-06 22:42 
I'm having some nasty problems with the MFC class CFileDialog. I'm simply trying to use it to get the name of a selected file and put it in a text edit box. I have done this many times before and have never had this sort of problem. Here is the code that is producing the error:

void CUpload::OnBrowse() 
{
	// TODO: Add your control notification handler code here

	static TCHAR BASED_CODE szFilter[] = "Windows Setup file (*.exe; *.EXE; *.msi ;*.MSI)|*.exe ;*.EXE;*.msi;*.MSI||";	

	CFileDialog oFileDlg(TRUE,"exe","",OFN_FILEMUSTEXIST|OFN_NOCHANGEDIR, szFilter);	
	oFileDlg.m_ofn.lpstrTitle = "Select the Installable Application";			

	
	if(oFileDlg.DoModal() == IDOK)
	{
		m_strloc = oFileDlg.GetPathName();

		GetDlgItem(IDC_FILELOC)->SetWindowText(m_strloc);
	}	
	

		
}


IDC_FILELOC is the id of the editbox and m_strloc is the variable of the edit box.

When I press the 'browse' (which calls void CUpload::OnBrowse() button the CFileDialog is created and DoModal() is called (causing the dialog to appear). It then lets me select a file. If I press 'Open' it returns IDOK and the file name gets put into the text edit box. If I select 'Cancel' IDCANCEL is returned and anything inside the text edit box is cleared (as it should be). The error doesn't occur untill the destructor is called. Which of course happens when the CFileDialog goes out of scope as soon as the function. Everything I have before then works correctly (I used message boxes to stop determine the point just before it crashes). I even commented out everything but the constructor and still got an error when the destructor is called.

The error message it says when the program crashes when I run it through the debugger says, "Unhandled exception in File Splitter.exe (KERNEL32.DLL): 0xC0000005: Access Violation."

KERNEL32! 7c80979d()
CFileDialog::~CFileDialog() + 71 bytes
CUpload::OnBrowse() line 78 + 18 bytes
_AfxDispatchCmdMsg(CCmdTarget * 0x0012f564 {CUpload hWnd=0x00080786}, unsigned int 1004, int 0, void (void)* 0x00401659 CUpload::OnBrowse(void), void * 0x00000000, unsigned int 12, AFX_CMDHANDLERINFO * 0x00000000) line 88
CCmdTarget::OnCmdMsg(unsigned int 1004, int 0, void * 0x00000000, AFX_CMDHANDLERINFO * 0x00000000) line 302 + 39 bytes
CDialog::OnCmdMsg(unsigned int 1004, int 0, void * 0x00000000, AFX_CMDHANDLERINFO * 0x00000000) line 97 + 24 bytes
CWnd::OnCommand(unsigned int 1004, long 133210) line 2088
CWnd::OnWndMsg(unsigned int 273, unsigned int 1004, long 133210, long * 0x0012efe0) line 1597 + 28 bytes
CWnd::WindowProc(unsigned int 273, unsigned int 1004, long 133210) line 1585 + 30 bytes
AfxCallWndProc(CWnd * 0x0012f564 {CUpload hWnd=0x00080786}, HWND__ * 0x00080786, unsigned int 273, unsigned int 1004, long 133210) line 215 + 26 bytes
AfxWndProc(HWND__ * 0x00080786, unsigned int 273, unsigned int 1004, long 133210) line 368
AfxWndProcBase(HWND__ * 0x00080786, unsigned int 273, unsigned int 1004, long 133210) line 220 + 21 bytes
USER32! 77d48709()
USER32! 77d487eb()
USER32! 77d4b743()
USER32! 77d4b7ab()
COMCTL32! 773f6ff6()
COMCTL32! 773f70d8()
COMCTL32! 773f93dd()
USER32! 77d48709()
USER32! 77d487eb()
USER32! 77d489a5()
USER32! 77d489e8()
USER32! 77d6e819()
USER32! 77d65ce2()
CWnd::IsDialogMessageA(tagMSG * 0x004b3228 {msg=0x00000202 wp=0x00000000 lp=0x000a0009}) line 182
CWnd::PreTranslateInput(tagMSG * 0x004b3228 {msg=0x00000202 wp=0x00000000 lp=0x000a0009}) line 3424
CDialog::PreTranslateMessage(tagMSG * 0x004b3228 {msg=0x00000202 wp=0x00000000 lp=0x000a0009}) line 92
CWnd::WalkPreTranslateTree(HWND__ * 0x0007028e, tagMSG * 0x004b3228 {msg=0x00000202 wp=0x00000000 lp=0x000a0009}) line 2667 + 18 bytes
CWinThread::PreTranslateMessage(tagMSG * 0x004b3228 {msg=0x00000202 wp=0x00000000 lp=0x000a0009}) line 665 + 18 bytes
CWinThread::PumpMessage() line 841 + 30 bytes
CWnd::RunModalLoop(unsigned long 4) line 3478 + 19 bytes
CDialog::DoModal() line 536 + 12 bytes
CBookMarks::OnUpload() line 494
_AfxDispatchCmdMsg(CCmdTarget * 0x00d32050 {CBookMarks hWnd=0x00040730}, unsigned int 1029, int 0, void (void)* 0x00402540 CBookMarks::OnUpload(void), void * 0x00000000, unsigned int 12, AFX_CMDHANDLERINFO * 0x00000000) line 88
CCmdTarget::OnCmdMsg(unsigned int 1029, int 0, void * 0x00000000, AFX_CMDHANDLERINFO * 0x00000000) line 302 + 39 bytes
CView::OnCmdMsg(unsigned int 1029, int 0, void * 0x00000000, AFX_CMDHANDLERINFO * 0x00000000) line 159 + 24 bytes
CWnd::OnCommand(unsigned int 1029, long 329478) line 2088
CWnd::OnWndMsg(unsigned int 273, unsigned int 1029, long 329478, long * 0x0012f834) line 1597 + 28 bytes
CWnd::WindowProc(unsigned int 273, unsigned int 1029, long 329478) line 1585 + 30 bytes
AfxCallWndProc(CWnd * 0x00d32050 {CBookMarks hWnd=0x00040730}, HWND__ * 0x00040730, unsigned int 273, unsigned int 1029, long 329478) line 215 + 26 bytes
AfxWndProc(HWND__ * 0x00040730, unsigned int 273, unsigned int 1029, long 329478) line 368
AfxWndProcBase(HWND__ * 0x00040730, unsigned int 273, unsigned int 1029, long 329478) line 220 + 21 bytes
USER32! 77d48709()
USER32! 77d487eb()
USER32! 77d4b743()
USER32! 77d4b7ab()
COMCTL32! 773f6ff6()
COMCTL32! 773f70d8()
COMCTL32! 773f93dd()
USER32! 77d48709()
USER32! 77d487eb()
USER32! 77d4c00e()
USER32! 77d4e366()
CWnd::DefWindowProcA(unsigned int 514, unsigned int 0, long 786520) line 1000 + 32 bytes
CWnd::WindowProc(unsigned int 514, unsigned int 0, long 786520) line 1586 + 26 bytes
AfxCallWndProc(CWnd * 0x00d32150 {CButton hWnd=0x00050706}, HWND__ * 0x00050706, unsigned int 514, unsigned int 0, long 786520) line 215 + 26 bytes
AfxWndProc(HWND__ * 0x00050706, unsigned int 514, unsigned int 0, long 786520) line 368
AfxWndProcBase(HWND__ * 0x00050706, unsigned int 514, unsigned int 0, long 786520) line 220 + 21 bytes
USER32! 77d48709()
USER32! 77d487eb()
USER32! 77d489a5()
USER32! 77d489e8()
USER32! 77d6e819()
USER32! 77d65ce2()
CWnd::IsDialogMessageA(tagMSG * 0x004b3228 {msg=0x00000202 wp=0x00000000 lp=0x000a0009}) line 182
CWnd::PreTranslateInput(tagMSG * 0x004b3228 {msg=0x00000202 wp=0x00000000 lp=0x000a0009}) line 3424
CFormView::PreTranslateMessage(tagMSG * 0x004b3228 {msg=0x00000202 wp=0x00000000 lp=0x000a0009}) line 213
CWnd::WalkPreTranslateTree(HWND__ * 0x0007028e, tagMSG * 0x004b3228 {msg=0x00000202 wp=0x00000000 lp=0x000a0009}) line 2667 + 18 bytes
CWinThread::PreTranslateMessage(tagMSG * 0x004b3228 {msg=0x00000202 wp=0x00000000 lp=0x000a0009}) line 665 + 18 bytes
CWinThread::PumpMessage() line 841 + 30 bytes
CWinThread::Run() line 480 + 11 bytes
CWinApp::Run() line 400
AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f04, int 1) line 49 + 11 bytes
WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f04, int 1) line 30
WinMainCRTStartup() line 330 + 54 bytes
KERNEL32!


And here is a disassembly immediately surrounding the code that execution stops on.

7C80979D   lock xadd   dword ptr [ecx],eax


Any help regardning this ........
AnswerRe: Problem with CFileDialog (access violation). Pin
Rajesh R Subramanian26-Oct-06 23:07
professionalRajesh R Subramanian26-Oct-06 23:07 
GeneralRe: Problem with CFileDialog (access violation). Pin
kiranin26-Oct-06 23:44
kiranin26-Oct-06 23:44 
GeneralRe: Problem with CFileDialog (access violation). Pin
Rajesh R Subramanian26-Oct-06 23:46
professionalRajesh R Subramanian26-Oct-06 23:46 
GeneralRe: Problem with CFileDialog (access violation). Pin
kiranin26-Oct-06 23:57
kiranin26-Oct-06 23:57 
GeneralRe: Problem with CFileDialog (access violation). Pin
Rajesh R Subramanian27-Oct-06 0:38
professionalRajesh R Subramanian27-Oct-06 0:38 
GeneralRe: Problem with CFileDialog (access violation). Pin
kiranin27-Oct-06 0:42
kiranin27-Oct-06 0:42 
AnswerRe: Problem with CFileDialog (access violation). Pin
David Crow27-Oct-06 4:48
David Crow27-Oct-06 4:48 
GeneralRe: Problem with CFileDialog (access violation). Pin
kiranin27-Oct-06 4:53
kiranin27-Oct-06 4:53 
QuestionRe: Problem with CFileDialog (access violation). Pin
David Crow27-Oct-06 5:16
David Crow27-Oct-06 5:16 
AnswerRe: Problem with CFileDialog (access violation). Pin
kiranin27-Oct-06 5:32
kiranin27-Oct-06 5:32 
Questionmenu item selection Pin
prithaa26-Oct-06 22:21
prithaa26-Oct-06 22:21 
AnswerRe: menu item selection Pin
Hamid_RT26-Oct-06 22:28
Hamid_RT26-Oct-06 22:28 
GeneralRe: menu item selection Pin
prithaa26-Oct-06 22:34
prithaa26-Oct-06 22:34 
AnswerRe: menu item selection Pin
bosfan26-Oct-06 22:34
bosfan26-Oct-06 22:34 
AnswerRe: menu item selection Pin
Michael Dunn26-Oct-06 23:05
sitebuilderMichael Dunn26-Oct-06 23:05 
GeneralRe: menu item selection Pin
prithaa27-Oct-06 0:41
prithaa27-Oct-06 0:41 
Questiondigital I/O Pin
Archyami26-Oct-06 22:19
Archyami26-Oct-06 22:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.