Any solution for the following problem

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(CMatchDoc),
            RUNTIME_CLASS(CMatchFrame), // custom MDI child frame
            RUNTIME_CLASS(CElectricityMatchView));

      AddDocTemplate(m_pElectricityMatchDocTemplate);

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

      AddDocTemplate(m_pThermalMatchDocTemplate);
        ......
********************************************
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);
      m_pElectricityMatchView->SetFrame(pMainFrame);//pMainFrame);
      m_pElectricityMatchView->SetSimPeriod(pMainFrame->GetpSimPeriod());
      ***********************************
The function of GetView() in details:
            ********************
            CElectricityMatchView* CElectricityMatchView::GetView()
            {

              CMDIChildWnd * pChild =
                         ((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive();
               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?
thanks!
junhongukAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

junhongukAuthor Commented:
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.

thanks.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.