把窗口静态分割后,想要让其中一个变成列表控件,请问如何实现?我在CMainFrame::OnCreateClient中做了如下修改:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
        CRect rc;
        GetClientRect(rc);
        CSize panesize(rc.Width(), rc.Height() / 2);
        m_wndSplitter.CreateStatic(this, 2, 1);
        m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CTView), panesize, pContext);
        m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CTlistView),panesize, pContext);//CTlistView是自己定义的列表类 return true;
//return CFrameWnd::OnCreateClient(lpcs, pContext);
}行不通~~~

解决方案 »

  1.   

    这样做,没有问题啊!
    你在CTlistView里面获取CListCtrl,然后添加一点数据看看,就知道切分窗口有没有正确的显示了!
      

  2.   

    先把这个问题放一边,帮我看看这是怎么回事:
    切分窗口遇到的问题。1. 用MFC新建SDI程序
    2. 在MainFrm.h中添加成员变量:
    protected:
    CSplitterWnd m_wndSplitter;
    3. 使用MFC class Wizard为CMainFrame类添加OnCreateClient函数的重载:
    BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
    {
    // TODO: Add your specialized code here and/or call the base class
    m_wndSplitter.CreateStatic(this, 1, 2);
    m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CTempView), CSize(200, 0), pContext);
    m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CTempView), CSize(200, 0), pContext);
    return true;
    //return CFrameWnd::OnCreateClient(lpcs, pContext);
    }
    4. 在MainFrm.cpp开始处添加包含文件:
    #include "TempView.h"然后出现三个错误提示,如下所示:d:\project\practice\temp\tempview.h(21) : error C2143: syntax error : missing ';' before '*'
    d:\project\practice\temp\tempview.h(21) : error C2501: 'CTempDoc' : missing storage-class or type specifiers
    d:\project\practice\temp\tempview.h(21) : error C2501: 'GetDocument' : missing storage-class or type specifiers
    请问为什么?