也可以不用CDocument,但是在各View之间传递消息更有难度。

解决方案 »

  1.   

    先建立一个CSplitterWnd变量,再重载CFrameWnd的OnCreateClient函数,在这个函数中调用变量的CSplitterWnd::CreateStatic 来分割窗口,再用CSplitterWnd::CreateView来为每个窗口建立视图。参照如果参数格式。
    BOOL CreateStatic( CWnd* pParentWnd, int nRows, int nCols, DWORD dwStyle = WS_CHILD | WS_VISIBLE, UINT nID = AFX_IDW_PANE_FIRST );Return ValueNonzero if successful; otherwise 0.ParameterspParentWndThe parent frame window of the splitter window.nRowsThe number of rows. This value must not exceed 16.nColsThe number of columns. This value must not exceed 16.dwStyleSpecifies the window style.nIDThe child window ID of the window. The ID can be AFX_IDW_PANE_FIRST unless the splitter window is nested inside another splitter window.
    =======================================================================
    virtual BOOL CreateView( int row, int col, CRuntimeClass* pViewClass, SIZE sizeInit, CCreateContext* pContext );Return ValueNonzero if successful; otherwise 0.ParametersrowSpecifies the splitter window row in which to place the new view.colSpecifies the splitter window column in which to place the new view.pViewClassSpecifies the CRuntimeClass of the new view.sizeInitSpecifies the initial size of the new view.pContextA pointer to a creation context used to create the view (usually the pContext passed into the parent frame’s overridden CFrameWnd::OnCreateClient member function in which the splitter window is being created).