returnCWnd::OnMouseActivate(pDesktopWnd,nHitTest,message);
}
voidCFormViewPrint::OnDestroy()
{
CWnd::OnDestroy();
//TODO:Addyourmessagehandlercodehere
}
voidCFormViewPrint::PostNcDestroy()
{
//TODO:Addyourspecializedcodehereand/orcallthebaseclass
CWnd::PostNcDestroy();
}
voidCFormViewPrint::OnActivateFrame(UINTnState,CFrameWnd*pDeactivateFrame)
{
//TODO:Addyourspecializedcodehereand/orcallthebaseclass
CWnd::OnActivateFrame(nState,pDeactivateFrame);
}
原因可参考
View和Control的区别(如何在对话框上使用CView类)
CView继承类,和其他窗口类的区别,很重要的就是对CDocument类和CFrameWnd类的操作,而其中,涉及CDocument类的操作,都进行了有效性判断(m_pDocument != NULL),CView类初始化的时候,m_pDocument = NULL,因此并不影响CView类作为控件的使用。涉及CFrame类的操作,有这么几个地方:
第一个地方:CView::OnDestroy()。cformview
void CView::OnDestroy()
{
CFrameWnd* pFrame = GetParentFrame();
if (pFrame != NULL && pFrame->GetActiveView() == this)
pFrame->SetActiveView(NULL);//deactivate during death
CWnd::OnDestroy();
}

第二个地方:CView::OnActivateFrame()。
void CView::OnActivateFrame(UINT , CFrameWnd* )
{
}
这里,其实是空的,在CView继承类中,只有CFormView类继承了这个虚函数
void CFormView::OnActivateFrame(UINT nState, CFrameWnd* )
{
if (nState == WA_INACTIVE)
SaveFocusControl();// save focus whenframe loses activation
}
实际上都不需要真的CFrame指针,对CView类作为控件使用没有障碍。
第三个地方:CView::OnMouseActivate()。cformview
int CView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
int nResult = CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
if (nResult == MA_NOACTIVATE || nResult == MA_NOACTIVATEANDEAT)
return nResult;// frame does not want to activate
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-32922-2.html
毕竟是有后台的公司
o