Get Document object from MainFrame class

For getting the document object in the Main Frame class, you have to get the CMDIChildWnd object. Using this object, you can call the function called GetActiveDoument(). This will return the document object.

CMDIChildWnd *pChild = MDIGetActive() ;
CMyDoc* pDoc = (CMyDoc*)pChild->GetActiveDocument() ;