我已经通过project->add to Project-->component and controls-->Visual C++ Components-->Splitter Bar实现了单文档窗口分割,是一行两列,系统给出的初始代码如下:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
    if (!m_wndSplitter.Create(this,1,2,CSize(10,10),pContext))
         {
              TRACE0("Failed to create splitter bar");
              return FALSE ;
         }
     return TRUE;
    
}现在我想在两个窗口中分别显示视图,于是添加后代码如下:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
    if (!m_wndSplitter.Create(this,1,2,CSize(10,10),pContext))
         {
              TRACE0("Failed to create splitter bar");
              return FALSE ;
         }
    if(!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CLeftView),Size(200,100),pContext)||
       !m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CZBGLView),Size(100,100),pContext))
       {
           m_wndSplitter.DestroyWindow();
           return FALSE ;
       }     return TRUE;
    
}
于是开始出错: 
             CLeftView:is not a class or namespace name
             classCLeftView:unDeclared identifier
             CZBGLView:is not a class or namespace name
             classCZBGLView:unDeclared identifier
我以为是没加头文件,于是添加头文件
               #include "LeftView.h"
             #include "ZBGLView.h"
但是这个时候又在主视图类的头文件中的同一行(CZBGLDoc* GetDocument();)报错:
             syntax error:missing ';' before '*'
             'CZBGLDoc':missing storage-class or type specifiers
             'GetDocument':missing storage-class or type specifiers
请各位看看是什么问题,麻烦各位费心了,谢谢

解决方案 »

  1.   

    m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CLeftView),Size(200,100),pContext)|| 
          !m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CZBGLView),Size(100,100),pContext)) 
    两个都是0,0位置创建??CreateView(0,0
    改改再试试,
    至于Document,不用的话就删除了吧,原因不明,碰到过,就删除了~
      

  2.   

     "ZBGLView.h" 里面是怎么写的?
      

  3.   

    http://www.vckbase.com/document/viewdoc/?id=192
    参看一下例子
      

  4.   

    实在不行在你得额外的View类实现中用extern出来,在主视图中使用
      

  5.   

    将CZBGLDoc类的头文件包含进来,注意一定要在
    #include "ZBGLView.h" 之前CRect rect;
    GetClientRect(&rect);
    m_wndSplitter.CreateStatic(this,2,1);
    m_wndSplitter.SetScrollStyle(0);
    m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CLeftView),CSize(rect.Width(),rect.Height()-rect.Height()/200),pContext);
    m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CZBGLView),CSize(rect.Width(),rect.Height()/200),pContext);
      

  6.   

    #include "ZBGLView.h" 要加在MainFrm.cpp文件中