注册 登录
编程论坛 VC.NET论坛

关于MFC中用m_WndSplitter.GetPane方法来获到视图指针出错

lbwxqh 发布于 2007-03-28 08:30, 5703 次点击

我的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

2 回复
#2
liuminghui2007-04-28 11:14
#3
心疼包2014-07-25 11:56
我也是这样啊
你的解决了吗
1