Document not created yet???
-
Hello, After deleting a control in a DialogBar, using in VC++ 6.0's Dialog Editor, my program crashes upon the following code execution in the DialogBar's class:
CGoalsDoc* pDoc = (CGoalsDoc*)((CMainFrame *) AfxGetApp()->m_pMainWnd)->GetActiveFrame()->GetActiveDocument();
The debugger says it's an "unhandled exception". It's as though my DialogBar is looking for a document that's doesn't yet exist yet? How would I go about debugging this issue? Clues: When commenting out the creation of my DialogBar in the CMainFrame class, the program gets further in the execution but crashes when trying to access the CMainFrame->m_DialogBar member. My change that caused this new behavior was the deletion of a CMonthCalendar Control from my DialogBar (and maybe the associated symbol). Any help would be appreciated! Thanks! JennyP -
Hello, After deleting a control in a DialogBar, using in VC++ 6.0's Dialog Editor, my program crashes upon the following code execution in the DialogBar's class:
CGoalsDoc* pDoc = (CGoalsDoc*)((CMainFrame *) AfxGetApp()->m_pMainWnd)->GetActiveFrame()->GetActiveDocument();
The debugger says it's an "unhandled exception". It's as though my DialogBar is looking for a document that's doesn't yet exist yet? How would I go about debugging this issue? Clues: When commenting out the creation of my DialogBar in the CMainFrame class, the program gets further in the execution but crashes when trying to access the CMainFrame->m_DialogBar member. My change that caused this new behavior was the deletion of a CMonthCalendar Control from my DialogBar (and maybe the associated symbol). Any help would be appreciated! Thanks! JennyPMore clue(s):
CWnd *test = AfxGetApp()->m_pMainWnd;
gives a null (0) value to test when this statement is inserted just before the statement in my previous message. Therefore, m_pMainWnd has not yet been assigned by MFC..... I'm not sure why this would suddenly stop working. Thanks for reading this so far. :) JennyP -
More clue(s):
CWnd *test = AfxGetApp()->m_pMainWnd;
gives a null (0) value to test when this statement is inserted just before the statement in my previous message. Therefore, m_pMainWnd has not yet been assigned by MFC..... I'm not sure why this would suddenly stop working. Thanks for reading this so far. :) JennyP:)can't understand clearly though what the real problem is..I can only help you in debugging. Put a breakpoint before the line you think it is creating exception and then pressing f10 f11 and shift f11 you can debug. I mean go back and forth in code to see where the actual problem occurs. Hope you find it soon.. cheers Himanshu
-
Hello, After deleting a control in a DialogBar, using in VC++ 6.0's Dialog Editor, my program crashes upon the following code execution in the DialogBar's class:
CGoalsDoc* pDoc = (CGoalsDoc*)((CMainFrame *) AfxGetApp()->m_pMainWnd)->GetActiveFrame()->GetActiveDocument();
The debugger says it's an "unhandled exception". It's as though my DialogBar is looking for a document that's doesn't yet exist yet? How would I go about debugging this issue? Clues: When commenting out the creation of my DialogBar in the CMainFrame class, the program gets further in the execution but crashes when trying to access the CMainFrame->m_DialogBar member. My change that caused this new behavior was the deletion of a CMonthCalendar Control from my DialogBar (and maybe the associated symbol). Any help would be appreciated! Thanks! JennyPI has this same problem just a few days ago in my derived OnFileNew handler of the CWinApp derived main program. I do some main frame control setup in the OnNewDocument() function but it would crash on startup. This solved the problem: void CMainApp::OnFileNew() { if((CMainFrame *)AfxGetMainWnd()) ((CMainFrame *)AfxGetMainWnd())->OnFileNew(); CWinApp::OnFileNew(); } You should be able to do the same thing in whatever derived function is eventually getting to the affected area. In some cases, the area that crashes has nothing to do with the actual code defect - it is just a side effect of uninitialized pointers (including class pointers) or stack corruption. Steve