bcg的sample里面有一个程序:TabbedView
用这样的方法来添加视图:AddView (RUNTIME_CLASS (CView1), _T("Simple"), 100);
AddView (RUNTIME_CLASS (CView2), _T("List"), 101);
AddView (RUNTIME_CLASS (CView3), _T("Form"), 102);
AddView (RUNTIME_CLASS (CView4), _T("ScrollView"), 102);我想CView1,2,3,4跟文档关联起来,该怎么做呢?
有没有代码?着急啊,高手帮忙了

解决方案 »

  1.   

    用CreateView来创建新的视图,这个函数的最后一个参数可以制定文档, 参考下面的代码pView   =   new   CXXXView;   
    CRuntimeClass   *   pViewClass   =   RUNTIME_CLASS(CXXXView);   
    CCreateContext   context;   
    context.m_pCurrentFrame   =   NULL;   
    context.m_pCurrentDoc   =   pXXXDoc;   
    context.m_pNewViewClass   =   pViewClass;   
    context.m_pNewDocTemplate   =   NULL;   
        
    CRect   rc;   
    CWnd   *pParentWnd   =   new   CWnd;   
    pParentWnd->Attach(m_hParent);   
    pParentWnd->GetClientRect(&rc);   
        
    pXXXView->Create(NULL,NULL,WS_CHILD|WS_VISIBLE,rc,pParentWnd,11,&context);
      

  2.   

    I look the sample of tabviewview,but i have a question:
    now i have a view named CView1,also,this view associate with a Document CDoc1,then how can i do?
    if I do this:
    AddView (RUNTIME_CLASS (CView1), _T("aaa"), 100);
    then how can i associate with my doc?
    if I do this:
    CCreateContext context; 
    context.m_pCurrentFrame = NULL; 
    context.m_pCurrentDoc = pDoc1 ; 
    context.m_pNewViewClass = pViewClass; 
    context.m_pNewDocTemplate = NULL; 
    AddView (RUNTIME_CLASS (CView1), _T("aaa"), 100,&context);then error! how can i do? help me,thanks