先用SetRowInfo()/SetColumnInfo()设置行列的信息。
然后RecalcLayout()

解决方案 »

  1.   

    好的,这是头文件childframe.h// ChildFrm.h : interface of the CChildFrame class
    //
    /////////////////////////////////////////////////////////////////////////////#if !defined(AFX_CHILDFRM_H__7838DE2B_5056_11D5_8175_0050FCFF00CB__INCLUDED_)
    #define AFX_CHILDFRM_H__7838DE2B_5056_11D5_8175_0050FCFF00CB__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    class CChildFrame : public CMDIChildWnd
    {
    DECLARE_DYNCREATE(CChildFrame)
    public:
    CChildFrame();// Attributes
    public:// Operations
    public:// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CChildFrame)
    public:
    virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
    protected:
    virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
    //}}AFX_VIRTUAL// Implementation
    public:
    virtual ~CChildFrame();
    #ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
    #endif// Generated message map functions
    protected:
    CSplitterWnd m_wndSplitter;
    //{{AFX_MSG(CChildFrame)
    // NOTE - the ClassWizard will add and remove member functions here.
    //    DO NOT EDIT what you see in these blocks of generated code!
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_CHILDFRM_H__7838DE2B_5056_11D5_8175_0050FCFF00CB__INCLUDED_)
    这是cpp
    // ChildFrm.cpp : implementation of the CChildFrame class
    //#include "stdafx.h"
    #include "Note.h"#include "ChildFrm.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CChildFrameIMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
    //{{AFX_MSG_MAP(CChildFrame)
    // NOTE - the ClassWizard will add and remove mapping macros here.
    //    DO NOT EDIT what you see in these blocks of generated code !
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CChildFrame construction/destructionCChildFrame::CChildFrame()
    {
    // TODO: add member initialization code here

    }CChildFrame::~CChildFrame()
    {
    }BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs if( !CMDIChildWnd::PreCreateWindow(cs) )
    return FALSE; return TRUE;
    }/////////////////////////////////////////////////////////////////////////////
    // CChildFrame diagnostics#ifdef _DEBUG
    void CChildFrame::AssertValid() const
    {
    CMDIChildWnd::AssertValid();
    }void CChildFrame::Dump(CDumpContext& dc) const
    {
    CMDIChildWnd::Dump(dc);
    }#endif //_DEBUG/////////////////////////////////////////////////////////////////////////////
    // CChildFrame message handlersBOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
    {
    // TODO: Add your specialized code here and/or call the base class
    return m_wndSplitter.Create(this, 2, 1, CSize(20, 20), pContext,WS_CHILD|WS_VISIBLE|WS_VSCROLL|SPLS_DYNAMIC_SPLIT);
    //return CMDIChildWnd::OnCreateClient(lpcs, pContext);
    }这是CNoteView.cpp
    // NoteView.cpp : implementation of the CNoteView class
    //#include "stdafx.h"
    #include "Note.h"#include "NoteDoc.h"
    #include "NoteView.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CNoteViewIMPLEMENT_DYNCREATE(CNoteView, CEditView)BEGIN_MESSAGE_MAP(CNoteView, CEditView)
    //{{AFX_MSG_MAP(CNoteView)
    ON_COMMAND(ID_TOOLS_SETFONT, OnToolsSetfont)
    ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
    //}}AFX_MSG_MAP
    // Standard printing commands
    ON_COMMAND(ID_FILE_PRINT, CEditView::OnFilePrint)
    ON_COMMAND(ID_FILE_PRINT_DIRECT, CEditView::OnFilePrint)
    ON_COMMAND(ID_FILE_PRINT_PREVIEW, CEditView::OnFilePrintPreview)
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CNoteView construction/destructionCNoteView::CNoteView()
    {
    // TODO: add construction code here
    memset(&m_logfont, 0, sizeof(m_logfont));
      m_nPointSize = 120;
      _tcscpy(m_logfont.lfFaceName, _T("Fixedsys")); // start out with a system font CWindowDC dc(NULL);
    m_logfont.lfHeight = ::MulDiv(m_nPointSize, dc.GetDeviceCaps(LOGPIXELSY), 720);
    m_logfont.lfPitchAndFamily = FIXED_PITCH; m_pFont = new CFont;
    m_pFont->CreateFontIndirect(&m_logfont);
    }CNoteView::~CNoteView()
    {
    if (m_pFont != NULL)
    delete m_pFont;
    }BOOL CNoteView::PreCreateWindow(CREATESTRUCT& cs)
    {
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs BOOL bPreCreated = CEditView::PreCreateWindow(cs);
    cs.style &= ~(ES_AUTOHSCROLL|WS_HSCROLL); // Enable word-wrapping return bPreCreated;
    }/////////////////////////////////////////////////////////////////////////////
    // CNoteView drawingvoid CNoteView::OnDraw(CDC* pDC)
    {
    CNoteDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    // TODO: add draw code for native data here
    }/////////////////////////////////////////////////////////////////////////////
    // CNoteView printingBOOL CNoteView::OnPreparePrinting(CPrintInfo* pInfo)
    {
    // default CEditView preparation
    return CEditView::OnPreparePrinting(pInfo);
    }void CNoteView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
    {
    // Default CEditView begin printing.
    CEditView::OnBeginPrinting(pDC, pInfo);
    }void CNoteView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
    {
    // Default CEditView end printing
    CEditView::OnEndPrinting(pDC, pInfo);
    }/////////////////////////////////////////////////////////////////////////////
    // CNoteView diagnostics#ifdef _DEBUG
    void CNoteView::AssertValid() const
    {
    CEditView::AssertValid();
    }void CNoteView::Dump(CDumpContext& dc) const
    {
    CEditView::Dump(dc);
    }CNoteDoc* CNoteView::GetDocument() // non-debug version is inline
    {
    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CNoteDoc)));
    return (CNoteDoc*)m_pDocument;
    }
    #endif //_DEBUG/////////////////////////////////////////////////////////////////////////////
    // CNoteView message handlersvoid CNoteView::OnToolsSetfont() 
    {
    // TODO: Add your command handler code here // let the user change their mind about the font

    LOGFONT lfCopy;
    memcpy(&lfCopy, &m_logfont, sizeof(lfCopy)); // pop up the existing font in the dialog CFontDialog dlg(&lfCopy);
    dlg.m_cf.Flags |= CF_FORCEFONTEXIST | CF_FIXEDPITCHONLY; // if they say so, create the font and put it in a 
    // member variable for use later if (dlg.DoModal() == IDOK)
    {
    CFont* pFontCopy = new CFont;
    if (pFontCopy->CreateFontIndirect(&lfCopy))
    {
    m_nPointSize = dlg.GetSize();
    if (m_pFont != NULL)
    delete m_pFont; m_pFont = pFontCopy;
    memcpy(&m_logfont, &lfCopy, sizeof(lfCopy));
    CNoteView::SetFont(m_pFont,TRUE);
       Invalidate();
    }
    else
    {
    delete pFontCopy;
    MessageBox(_T("不能创建新字体!"));
    }
    }  
    }//DEL void CNoteView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
    //DEL {
    //DEL  // TODO: Add your message handler code here and/or call default
    //DEL  CDocument* pDocument=GetDocument();
    //DEL  CNoteDoc* pDoc=GetDocument();
    //DEL  GetWindowText(pDoc->m_strText);
    //DEL  pDocument->UpdateAllViews(this,NULL,NULL);
    //DEL  CEditView::OnKeyUp(nChar, nRepCnt, nFlags);
    //DEL }void CNoteView::OnInitialUpdate() 
    {
    CEditView::OnInitialUpdate();

    // TODO: Add your specialized code here and/or call the base class
    ShowScrollBar(1,FALSE); CNoteDoc* pDoc=GetDocument();
    SetWindowText(pDoc->m_strText.GetBuffer(pDoc->m_strText.GetLength()));
    }void CNoteView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
    {
    // TODO: Add your specialized code here and/or call the base class
    CNoteDoc* pDoc = GetDocument();
    SetWindowText(pDoc->m_strText.GetBuffer(pDoc->m_strText.GetLength()));

    }void CNoteView::OnChange() 
    {
    // TODO: If this is a RICHEDIT control, the control will not
    // send this notification unless you override the CEditView::OnInitDialog()
    // function and call CRichEditCtrl().SetEventMask()
    // with the ENM_CHANGE flag ORed into the mask.

    // TODO: Add your control notification handler code here
    CDocument* pDocument=GetDocument();
    CNoteDoc* pDoc=GetDocument();
    GetWindowText(pDoc->m_strText);
    pDocument->UpdateAllViews(this,NULL,NULL);
    pDoc->SetModifiedFlag(TRUE);
    }
      

  2.   

    “为的是只用CSplitterWnd的滚动条”,为什么不用CEditView的滚动条?????
      

  3.   

    如果使用CEditView的滚动条,那么我的窗口怎么拆分?也就是说,滚动条上就没有拆分窗口的手柄了!!是不是呢?