1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MFC: How MDI Tabbed window works

Discussion in 'Help and Support' started by ppp, Apr 7, 2016.

  1. ppp

    ppp New Member

    Joined:
    Apr 7, 2016
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I have an application(MDI Tabbed) type.

    I am facing the below described issue in tabbed documeent.

    I have opened a single document(i.s a single tab is present in the frame). I hide the tab in my progamming. Then opened a new document, when i am trying to unhide the earlier tab by addTab API, it shows two tabs with same name and when closing it, it crashes.
    Code:
     const CObList& tabGroups = pMainFrame->GetMDITabGroups();
              for (POSITION pos = tabGroups.GetHeadPosition(); NULL != pos;)
              {
               
                pNextTab = DYNAMIC_DOWNCAST(CMFCTabCtrl, tabGroups.GetNext(pos));
                ASSERT_VALID(pNextTab);
                if (NULL == pNextTab)
                  continue;
    
    
                int nTabMaxIndx = pNextTab->GetTabsNum();
                for (int nTabCurrIndx = 0; nTabCurrIndx < nTabMaxIndx; ++nTabCurrIndx)
                {
          
                  CMDIChildWndEx *pChildWnd = DYNAMIC_DOWNCAST(CMDIChildWndEx, pNextTab->GetTabWnd(nTabCurrIndx));
                  ASSERT(pChildWnd);
                  if (NULL == pChildWnd)
                    continue;
      
                  CWnd* pWnd = dynamic_cast<CView*> (pChildWnd->GetWindow(GW_CHILD));
                  if ((NULL != pWnd) && (pWnd->m_hWnd == pTemplateView->m_hWnd))
                  {
    
                    // virtual BOOL ShowTab(int iTab, BOOL bShow = TRUE, BOOL bRecalcLayout 
                    pNextTab->ShowTab(nTabCurrIndx, nCmdShow == SW_SHOWNORMAL ? TRUE : FALSE, TRUE, FALSE);
    				bTabFound = true;
                    break;
                  }
                }
              }
            }/
    
    		if((false == bTabFound) && (SW_SHOWNORMAL == nCmdShow))
    		{
    			pNextTab->AddTab(pWndTemplate, GetTitle(), (UINT)-1);
    		}
     

Share This Page