| « Using MFC: The Doc/View Print Loop | Parameter Reflection and Serialization » |
MFC: Doc/View & GetActiveDocument
One particularly unnerving thing in the MFC Document / View implementation is the fact that
CMDIFrameWnd::GetActiveDocument() function does return NULL, since it is not the window actually holding the document. You should use a function like the following one to get the document in the MDIFrameWnd:
CDocument* CMyFrame::GetActiveDocumentForSure()
{
// Get the active MDI child window.
CMDIChildWnd *child = MDIGetActive();
if (!child) return 0;
// Get the active view
CView *view = (CView *) child->GetActiveView();
if (!view) return 0;
// get the document from the view
return view->GetDocument();
}
by axel
2005-07-27. 18:04:51. 82 words, 5678 views. Categories: programming, C++, MFC , Leave a comment » • Send a trackback »
2005-07-27. 18:04:51. 82 words, 5678 views. Categories: programming, C++, MFC , Leave a comment » • Send a trackback »
Trackback address for this post
Trackback URL (right click and copy shortcut/link location)
Feedback awaiting moderation
This post has 1483 feedbacks awaiting moderation...