我的程序如下:
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext

{
    // TODO: Add your specialized code here and/or call the base class
    UINT myType;
    CMainFrame *pWnd;
    pWnd = (CMainFrame *)AfxGetApp()->m_pMainWnd;
    myType = pWnd->m_nType;
    if(myType == IDC_RADIO_TYPE1)
    {//显示第一类题目
        CRect rect;
        GetClientRect(&rect);
        CSize size = rect.Size();        CWnd* pWnd;
        pWnd = CreateView(pContext, AFX_IDW_PANE_FIRST);
    }
    if(myType == IDC_RADIO_TYPE2)
    {//显示第二类题目
        CRect rect;
        GetClientRect(&rect);
        CSize size = rect.Size();
        size.cx /= 2;
        size.cy /= 2;        //创建一个分割器
        if (!m_wndSplitter.CreateStatic(this, 1, 2))
        {
            TRACE0("Failed to create first static splitter\n");
            return FALSE;
        }        //创建左边的视图
        if(!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CPaperEditView), size
, pContext))
        {
            TRACE0("Failed to create left view\n");
            return FALSE;
        }
        //创建右边的视图
        if(!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CPaperSrcView), size,
 pContext))
        {
            TRACE0("Failed to create right view\n");
            return FALSE;
        }
        SetActiveView((CView*)m_wndSplitter.GetPane(0,0));
        return TRUE;    
    }
    else
    {
        return FALSE;
    }    return CMDIChildWnd::OnCreateClient(lpcs, pContext);
}//在app中的声明
    m_ptTemplate1 = new CMultiDocTemplate(
        IDR_PAPERETYPE,
        RUNTIME_CLASS(CPaperEditDoc),
        RUNTIME_CLASS(CChildFrame), // custom MDI child frame
        NULL);                      //填充类试题使用切分窗口
    m_ptTemplate1->SetContainerInfo(IDR_PAPERETYPE_CNTR_IP);
    AddDocTemplate(m_ptTemplate1);

解决方案 »

  1.   

    我是在显示第一类题目时创建一个视图,此时出现ASSERT错误
      

  2.   

    1、代码: 
    CMainFrame *pWnd;
        pWnd = (CMainFrame *)AfxGetApp()->m_pMainWnd;
        myType = pWnd->m_nType;pWnd 可能为空。2、 CWnd* pWnd;
            pWnd = CreateView(pContext, AFX_IDW_PANE_FIRST);
    可试一试 if  (!CreateView (CreateView(pContext, AFX_IDW_PANE_FIRST))
    {}
    else
    {
       //出错处理。
    }
      

  3.   

    我的问题已解决,在vc 6.0下总不行,在vc .net下就没问题