这是应用程序框架生成的代码:在这里进行动态拆分(即可以只显示一个也可以拆分为2个或4个窗口)
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
return m_wndSplitter.Create(this,
2, 2,               // TODO: 调整行数和列数
CSize(10, 10),      // TODO: 调整最小窗格大小
pContext);
}在调用CSplitterWnd类成员m_wndSplitter的成员函数Create中的第三、四个参数不能大于2,就是说只能拆分2*2的,那么如果要大于2*2的4窗口是怎么做呢?注:这是MSDN的说明:
virtual BOOL Create(
   CWnd* pParentWnd,
   int nMaxRows,
   int nMaxCols,
   SIZE sizeMin,
   CCreateContext* pContext,
   DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | SPLS_DYNAMIC_SPLIT,
   UINT nID = AFX_IDW_PANE_FIRST 
);
nMaxRows
The maximum number of rows in the splitter window. This value must not exceed 2.nMaxCols
The maximum number of columns in the splitter window. This value must not exceed 2.

解决方案 »

  1.   

    if (!m_wndSplitter.CreateStatic(this, 2, 1))
    return -1; if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CWWWView), CSize(100, 30), pContext) ||
    !m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CWWWView), CSize(0, 100), pContext))
    {
    m_wndSplitter.DestroyWindow();
    return -1;
    }用静态拆分吧,类似上边的代码,想怎么拆就怎么拆,不够多了就把拆好的窗口继续拆