No matter what I do, GetActiveDocument() seems to always return NULL. For example, I build a MDI app called Test using VC++5, accepting all the Wizard defaults. Then I add a menu item called Test, and add a handler to the CTestView class as shown below:
CTestDoc* pDoc = GetDocument();
CFrameWnd* pFrame = DYNAMIC_DOWNCAST(CFrameWnd,theApp.m_pMainWnd);
CDocument* pGenericDoc = pFrame->GetActiveDocument();
CTestDoc* pTestDoc = DYNAMIC_DOWNCAST(CTestDoc,pGenericDoc);
theApp is the CTestApp instance produced by the wizard; I add "extern CTestApp theApp;" at the top of TestView.cpp.
When I run the app, I of course get the standard initial blank document, so THERE IS an active document, and sure enough, the call to CTestView::GetDocument returns non-null (I put this in just to make sure I wasn't nuts). The rest of the code in the handler is copied from Mike Blaszczak's "Professional MFC" book, page 185, which gives an example of how you get a pointer to the current document from some place other than your view class.
Anyway, the ASSERT(pGenericDoc) always blows. pFrame is non-NULL, but maybe isn't initialized by MFC to actually point to the main window?? Have I maybe found something that works under NT but not 95??