mfctabcontrolcview

MFC: How do I get the CView* of a tab in a CTabView?


I have a CTabView and add a tab like AddView(RUNTIME_CLASS(CMyView1), _T("View1"));. But how do I get a pointer to the created CMyView1 class created in the tab?

TIA!!


Solution

  • You can do something like this:

    CMFCTabCtrl& MFCTabCtrl = YourTabView.GetTabControl();
    for(int i = 0;i < MFCTabCtrl.GetTabsNum();++i)
    {
        CMyView1* pView = (CMyView1*)MFCTabCtrl.GetTabWnd(i);
        ....
    }