Click here to Skip to main content
15,886,873 members

Comments by cc.caprani (Top 3 by date)

cc.caprani 13-Apr-11 12:21pm View    
It didn't compile because the MyDoc.h wasn't included in the MyView.h file. I wasn't sure if cross-including them would lead to melt down so I hadn't before this. After including the View.h in MainFrame.cpp and MyDoc.h in MyView.h it compiles and the above code works. I can now handle the closing of the thread locally to the CView class. Of course I have other problems now....!!

Thanks for your help in solving this Joan!
cc.caprani 13-Apr-11 12:09pm View    
I tried this already, but maybe I did it wrong:

void CMainFrame::OnClose()
{
CMyView* pView = (CMyView*)((CFrameWnd*)AfxGetMainWnd())->GetActiveView();
ASSERT_VALID(pView);
pView->OnClose();
CFrameWnd::OnClose();
}

I include MyView.h in the top of the MainFrame.cpp file. It won't compile then though :(

Thanks again for your help!
cc.caprani 13-Apr-11 11:30am View    
Joan,
Thanks for replying. Can I be bold and ask two follow up questions to your solutions?!
1. Where should I handle the WM_CLOSE message so that it doesn't get called after the CDocument is already destroyed. I tried handling it from the CView class and it didn't work. If I try to handle it from CMainFrame then I need to access CView (where the threads lives) but I can't include MyView.h in MainFrame.h - tried it!
2. I'd like to process the interruption, but this is the essence of my problem - how do I do this? OnClose() in CView is too far down the terminating chain.
Thanks again for your help!