Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Document not created yet???

Document not created yet???

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++debuggingquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JennyP
    wrote on last edited by
    #1

    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

    J S 2 Replies Last reply
    0
    • J 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! JennyP

      J Offline
      J Offline
      JennyP
      wrote on last edited by
      #2

      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

      X 1 Reply Last reply
      0
      • J 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

        X Offline
        X Offline
        xxhimanshu
        wrote on last edited by
        #3

        :)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

        1 Reply Last reply
        0
        • J 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! JennyP

          S Offline
          S Offline
          Steve Mayfield
          wrote on last edited by
          #4

          I 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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups