我的CMainFrame类中OnCreateClient函数如下写的
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if (!m_wndSplitter.CreateStatic(this, 1, 3,WS_CHILD | WS_VISIBLE))
{
TRACE("Failed to CreateStaticSplitter\n");
return FALSE;
}
// First splitter pane
if (!m_wndSplitter.CreateView(0, 0,
RUNTIME_CLASS(FormLeft), CSize(110,160), pContext))
{
TRACE("Failed to create command view pane\n");
return FALSE;
}
// Second splitter pane
if (!m_wndSplitter.CreateView(0, 1,
RUNTIME_CLASS(CsitView), CSize(510,200), pContext))
{
TRACE("Failed to create preview pane\n");
return FALSE;
}
if (!m_wndSplitter.CreateView(0, 2,
RUNTIME_CLASS(FormRight), CSize(150,160), pContext))
{
TRACE("Failed to create command view pane\n");
return FALSE;
}
return TRUE;
}
然后在一另一个类中如下来调用视图类指针
CsitView* FormLeft::FormLeft_getview(void)
{
CMainFrame *pframe=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CsitView *pview=(CsitView*)pframe->m_wndSplitter.GetPane(0,1);
return pview;
}
CsitView是我的视图类
但运行的结果是,报错信息为:
Debug Assertion Failed!
File:winsplit.cpp
Line:344
For information on how your program can cause an assertion failure,see the VC documentation on asserts