我想把一個SDI程序的視圖切分成3行,相關的代碼如下.
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
    // TODO: Add your specialized code here and/or call the base class
    CRect cr;
    GetClientRect(&cr);
    CSize paneSize(cr.Width()/3,cr.Height()/3);    m_wndSplitter.CreateStatic(this,3,1);    m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CMyView),paneSize,pContext);
    m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CMyView),paneSize,pContext);
    m_wndSplitter.CreateView(2,0,RUNTIME_CLASS(CMyView),paneSize,pContext);
    return TRUE;
    
    //return CFrameWnd::OnCreateClient(lpcs, pContext);
}
其中CMyView是我自己建立的一個從CFormView繼承的類,但是為甚麼我一運行就出現紅色框,提示程序出錯,讓我'終止','繼續','忽略'.
為甚麼會這樣,還請大家幫個忙.

解决方案 »

  1.   

    BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
    CCreateContext* pContext)
    {

     if(m_wndSplitter1.CreateStatic(this,1,2)==NULL) 
          return FALSE; 
        //左边窗口:
        m_wndSplitter1.CreateView(0,0,RUNTIME_CLASS(CGyView),CSize(200,200), pContext); 
        //再把右边窗口分成两行一列:
        if(m_wndSplitter2.CreateStatic(&m_wndSplitter1,2,1,
    WS_CHILD|WS_VISIBLE, m_wndSplitter1.IdFromRowCol(0,1))==NULL) 
          return FALSE;  
        //右边上半部分窗口:
        m_wndSplitter2.CreateView(0,0,RUNTIME_CLASS(CLfet1View),CSize(400,300),pContext); 
        //右边下半部分窗口:
        m_wndSplitter2.CreateView(1,0,RUNTIME_CLASS(Cbuttomview),CSize(100,100),pContext); 
        return TRUE; 
    }
    参考一下吧!