open file and open new data in tab control

I am use a SDI app that has Data that is stored in a class that is called in CMyDoc.  I've added a tab control to my app using an example that I found at http://www.codersource.net/mfc_ctabctrl.html . Before I added the tab, I viewed and edited my data in CMyView and when I opened my Data file or opened new, they worked.  When I added the tab control and used it to manipulate the data in the tabs, my open new and open file stopped working.  I need help finding out why.
Whenever I open new or open existing, I get a debug assertion failure on file wincore.cpp line 628.
dociebAsked:
Who is Participating?
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.

hemakumarCommented:
U mean to say file new and file open?i
hemakumarCommented:
did u handle those menuitems anywhere like view or someother class.
dociebAuthor Commented:
I call newdocument in CMyDoc and in newdocument I call to view it with a function in CMyView, like this:
BOOL CMyDoc::OnNewDocument()
{
      if (!CDocument::OnNewDocument())
            return FALSE;
      if (!AddMrec()||!AddAnrec()||!AddPrec())
            return FALSE;
      POSITION pos = GetFirstViewPosition();
      CMyView* pView = (CMyView*)GetNextView(pos);
      if (pView)
            pView->NewDataSet();
      return TRUE;
}
void CMyView::NewDataSet()
{
      CMyDoc * pDoc = GetDocument();
      if (pDoc)
      {
//            m_tbCtrl. m_Dialog[0]->SendMessage ( WM_MUPDATEDATA ,  0 , (LPARAM )0);
//            m_tbCtrl. m_Dialog[1]->SendMessage ( WM_AUPDATEDATA ,  0 , (LPARAM )0);
//            m_tbCtrl. m_Dialog[2]->SendMessage ( WM_PUPDATEDATA ,  0 , (LPARAM )0);
      }
}
which the 3 lines I have commented out will cause the program to crash when it first opens.  So, I guess part of my problem is viewing it.  With the 3 lines comment out, it will do the initial start but when I click on new file or open file, it crashes.
hemakumarCommented:
Write the above code in OnInitialUpdate instead of writing in OnNewDocument().The three lines were crashing because byt the time new document is called the child controls are not  created.

So override OnInitialUpdate virtual function in view class.

void CMyView::OnInitialUpdate()
{

this->NewDataSet();


}
void CMyView::NewDataSet()
{
          m_tbCtrl. m_Dialog[0]->SendMessage ( WM_MUPDATEDATA ,  0 , (LPARAM )0);
          m_tbCtrl. m_Dialog[1]->SendMessage ( WM_AUPDATEDATA ,  0 , (LPARAM )0);
          m_tbCtrl. m_Dialog[2]->SendMessage ( WM_PUPDATEDATA ,  0 , (LPARAM )0);
   
}
Test it and getback.

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
dociebAuthor Commented:
I already had OnInitialUpdate overrided.  I moved this->NewDataSet to OnInitialUpdate and it still didn't work but I ran through the debug to find where it is failing and I discovered that is was in OnInitialUpdate where I initialize the tabs, since they were already initialized, it was crashing when it tried initializing them again.  So I set up a flag that I checked to see if it was initialized, if it wasn't then initialize, else just update the values and it works now.  Thx.
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.