用MFC Wizard生成一个OLE Full Server,不支持Compound File,其他默认。
在View类里重载OnSetFocus()如下:
void CTestServerView::OnSetFocus(CWnd* pOldWnd)
{
CView::OnSetFocus(pOldWnd); // TODO: Add your message handler code here
// FrameWnd()->ShowControlBar(PToolBar(), bTest(), FALSE);
// ToolBar().Invalidate(); if (!theApp.m_bRunEmbedded && !theApp.m_bRunAutomated)
{
CMainFrame* pMainFrame = ((CMainFrame*)theApp.m_pMainWnd);
pMainFrame->ShowControlBar(&pMainFrame->m_wndToolBar, pMainFrame->m_bTest, FALSE);
pMainFrame->m_wndToolBar.Invalidate();
}
else
{
CInPlaceFrame* pIPFrame = ((CInPlaceFrame*)theApp.m_pIPFrame);
pIPFrame->ShowControlBar(&pIPFrame->m_wndToolBar, pIPFrame->m_bTest, FALSE);
pIPFrame->m_wndToolBar.Invalidate();
}
}其中各个类中新加成员,相信有OLE Server编程经验的人能够猜出应该在那里添加,如果需要全部原代码,我可以发过去。问题是:
在Stand Alone方式下,运行是正确的;但是在Embedded方式下,就会出现内存访问错误。