getting the active view in MDI + Doc/View application
hi group,
i want to get active view pointer and call it's member function
void CMainFrame::OnBuild()
{
CChildFrame* pChild = (CChildFrame *)MDIGetActive();
if(pChild)
{
CTritonSpiritBoardView *pView = (CTritonSpiritBoardView
*)pChild->GetActiveView();
if(pView)
{
pView->HighLightLine(Line);
}
}
}
in this function it work's fine.it's a message handler for one menu
item.
but now if i want to call the activeview's this function from some
other
class then it gives assertion on MDIGetActive.
//if i try it on dialog boxes OnOk function then it asserts
void CBoard::OnOk()
{
CMainFrame *pFrame = (CMainFrame *)AfxGetApp()->m_pMainWnd;
if(pFrame)
{
CChildFrame* pChild = (CChildFrame
*)pFrame->MDIGetActive();//here inside
if(pChild)
{
CTritonSpiritBoardView *pView = (CTritonSpiritBoardView
*)pChild->GetActiveView();
if(pView)
{
pView->HighLightLine(Line);
}
}
}
}
i didnot got this behaviour
and not only this if i create a public member function
in CMainFrame as Try()
void CMainFrame::Try()
{
CChildFrame* pChild = (CChildFrame *)MDIGetActive();//here inside
if(pChild)
{
CTritonSpiritBoardView *pView = (CTritonSpiritBoardView
*)pChild->GetActiveView();
if(pView)
{
pView->HighLightLine(Line);
}
}
}
then also it asserts?
WHY like this?
if anyone know's please tell me.
Thank's and regards
harshal shete