BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
// TODO: Add your specialized code here and/or call the base class
if(!m_wndSplitter.CreateStatic(this,1,2))
return FALSE; if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), 
                         CSize(228, 100), pContext) ||  
        !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CRightView), 
                         CSize(100, 100), pContext))  
{  
         m_wndSplitter.DestroyWindow();  
         return FALSE;  
}  
为什么运行这个就出错。我的CLeftView是从CFormView继承而来,我的CRightView也是从CFormView继承而来,编译都没问题,就是运行出错,还会出现创建空文档失败的错误。
return TRUE;// return CFrameWnd::OnCreateClient(lpcs, pContext);
}

解决方案 »

  1.   

    已经试过,重启VC了,还是老样子。
    我的两个对话框里,在CLeftView里添加了一个Tree控件,而在第二个CRightView里添加了一个List控件。为什么执行到第二个if语句就出错呢。
      

  2.   

    把第二个if拆成两条语句,然后调试时仔细看看每个变量。
    具体到这段程序,好象是RUNTIME_CLASS的问题。
      

  3.   

    你这样试试看:
    BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
    {
    // TODO: Add your specialized code here and/or call the base class
    BOOL ret=m_wndSplitter.CreateStatic(this,1,2);
             ret|=m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), 
                             CSize(228, 100), pContext);
            ret|=m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CRightView), 
                             CSize(100, 100), pContext);  
             
             return ret;  
    }  
    不要用那么多的if
      

  4.   

    代码没有问题,, 楼主debug进去看看是哪里错了