Any solution for the following problem

Posted on 2006-04-19
Last Modified: 2013-11-20
I want to add two views in the certain document in MDI application.
in the *App.cpp, I add the following codes to share the same doc.
      // create main MDI Frame window
      CMainFrame* pMainFrame = new CMainFrame;
      if (!pMainFrame->LoadFrame(IDR_MeritTYPE))
            return FALSE;

      m_pMainWnd = pMainFrame;

      m_pElectricityMatchDocTemplate = new CMultiDocTemplate(IDR_MERITMATCH,
            RUNTIME_CLASS(CMatchFrame), // custom MDI child frame


      m_pThermalMatchDocTemplate = new CMultiDocTemplate(IDR_MERITMATCH,
            RUNTIME_CLASS(CMatchFrame), // custom MDI child frame

when the program run until the following code:
      CDocument* pDoc = NULL;// m_pMatchDocTemplate->OpenDocumentFile(NULL,0);
      m_pElectricityMatchView = CElectricityMatchView::GetView();   //the pointer to the view is empty, why????

      ASSERT(m_pElectricityMatchView != NULL);
The function of GetView() in details:
            CElectricityMatchView* CElectricityMatchView::GetView()

              CMDIChildWnd * pChild =
               if ( !pChild )
              AfxMessageBox("pChild Error!");
                   return NULL;

               CView * pView = pChild->GetActiveView();

               if ( !pView )
              AfxMessageBox("pView Error!");
                  return NULL;

             // Fail if view is of wrong kind
             if ( ! pView->IsKindOf( RUNTIME_CLASS(CElectricityMatchView) ) )
              AfxMessageBox("pView->IsKindOf Error!");
                  return NULL;
              return (CElectricityMatchView*) pView;
I can't get the view of child window. why?
is anything wrong with the above code? any solution?
Question by:junhonguk

    Author Comment

    I have already sovled the problem. There is something wrong with my code.

    modified the specific code as follows:

        CDocument* pDoc = m_pMatchDocTemplate->OpenDocumentFile(NULL);
         m_pElectricityMatchView = CElectricityMatchView::GetView();  

    It will get the pointer of the view.



    Accepted Solution

    Closed, 300 points refunded.
    The Experts Exchange
    Community Support Moderator of all Ages

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Decoding 32 bit binary streams 6 20
    EvenOdd challenge 10 68
    FizzBuzz challenge 9 65
    Change to event 1 49
    Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
    Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now