我是这样分割一个SDI窗体的
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
// TODO: Add your specialized code here and/or call the base class
         CSplitterWnd m_sp2;
CSplitterWnd m_sp1;
m_sp1.CreateStatic(this,1,2);
m_sp1.CreateView (0,0,RUNTIME_CLASS(CView2),CSize(200,200),pContext);
m_sp1.CreateView (0,1,RUNTIME_CLASS(CView3),CSize(200,200),pContext);
return CFrameWnd::OnCreateClient(lpcs, pContext);
}其中CView2,CView3都是从CView派生来的!
这个程序编译没有错误,但是就是不能分割!!
到底是我们问题啊??

解决方案 »

  1.   

    m_sp1.CreateView (0,0,RUNTIME_CLASS(CView2),CSize(200,200),pContext);//你拆了一个视图后应该把原来的视图也做为新视图的部分吧。里面的CView2应该是拆分前的视图名吧看看这里是怎么做的。
    http://www.vckbase.com/document/viewdoc/?id=192
      

  2.   

    I think your return value should be changed.You have used default return value created by MFC.Advise you delete the defalut return value, and return TRUE. The Code Below:BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
    {
    // TODO: Add your specialized code here and/or call the base class
             CSplitterWnd m_sp2;
    CSplitterWnd m_sp1;
    m_sp1.CreateStatic(this,1,2);
    m_sp1.CreateView (0,0,RUNTIME_CLASS(CView2),CSize(200,200),pContext);
    m_sp1.CreateView (0,1,RUNTIME_CLASS(CView3),CSize(200,200),pContext);
    // return CFrameWnd::OnCreateClient(lpcs, pContext);
             return TRUE;
    }
      

  3.   

    你的m_sp1是个局部对象。其他的都没问题
    我做了个测试,只不同在CSplitterWnd对象是在MainFrame中定义的,结果运行没问题。我想该是那里的问题吧
      

  4.   

    感谢afxtian(IT民工) 啊,.果然是返回值的问题.