I have an MDI app with a CTabView that has 3 CView's (CView1, CView2, CView3) added as individual tabs...
Code:
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_TABBEDTYPE,
RUNTIME_CLASS(CTabbedViewDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CMyTabView));
AddDocTemplate(pDocTemplate);
I want to get a pointer to CMyTabView. I use the following code from MSDN (Accessing a view from anywhere) in an attempt to access CMyTabView but GetActiveView only gets the CView1.
How can I get a pointer to CMyTabView?
Code:
CMyTabView* CMyTabView::GetView()
{
CMDIChildWnd * pChild = ((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive();
if (!pChild )
return NULL;
CView* pView = pChild->GetActiveView();
if(!pView )
return NULL;
// Fail if view is of wrong kind
if(!pView->IsKindOf(RUNTIME_CLASS(CMyTabView) ) )
return NULL;
return (CMyTabView*) pView;
}