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

514 Views Asked by At

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!!

2

There are 2 best solutions below

0
On BEST ANSWER

You can do something like this:

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

Try to look at the MFC-MDI tab view Implementation, when you are talking about views, this is the easiest way.