890901 - getting the currently active child frame
-
hi what's the best method to get the currently active child frame window/ currently active view/ or document? consider we're in one of children of main frame or their children and have no access to any window.
-
hi what's the best method to get the currently active child frame window/ currently active view/ or document? consider we're in one of children of main frame or their children and have no access to any window.
Here is what use in my MDI applications:
// First get the MDI frame window
CMDIFrameWnd* pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;// !Here we get the active MDI child window!
CMDIChildWnd* pChild = (CMDIChildWnd*)pFrame->GetActiveFrame();// Alternatively you can use
// CMDIChildWnd* pChild = pFrame->MDIGetActive();// !Get the active view attached to the active MDI child window!
CMyView* pView = (CMyView*)pChild->GetActiveView();// !Get the active document!
CMyDoc* pDoc = (CMyDoc*)pChild->GetActiveDocument();:)
-
Here is what use in my MDI applications:
// First get the MDI frame window
CMDIFrameWnd* pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;// !Here we get the active MDI child window!
CMDIChildWnd* pChild = (CMDIChildWnd*)pFrame->GetActiveFrame();// Alternatively you can use
// CMDIChildWnd* pChild = pFrame->MDIGetActive();// !Get the active view attached to the active MDI child window!
CMyView* pView = (CMyView*)pChild->GetActiveView();// !Get the active document!
CMyDoc* pDoc = (CMyDoc*)pChild->GetActiveDocument();:)
oh thanks! i was mistaking:
CFrameWnd \*pFrameWnd = GetTopLevelFrame(); CView \*pView = pFrameWnd->GetActiveView();
and i wondered why it returned NULL. now i changed it into:
Ct2View *AcToolCtrl::pr_getActiveView()
{
CView *pView = GetTopLevelFrame()->GetActiveFrame()->GetActiveView();
ASSERT_KINDOF(Ct2View, pView);
return (Ct2View *)pView;
}and it worked. :)