本来用的是cview,后来改成cscrollview就出现了下面的问题。用的是vc2008
Debug Assertion Failed!progam:....
file:vctools/vc7libs/ship/atlmfc/src/mfc/viewscrl.cpp
Line:385

解决方案 »

  1.   

    要再initupdate函数中设置setscrollsizes()
      

  2.   

    添加类的时候本来就带了setscrollsizes()啊
      

  3.   


    void CELTestViewL::OnInitialUpdate()
    {
    CScrollView::OnInitialUpdate(); CSize sizeTotal;
    // TODO: calculate the total size of this view
    sizeTotal.cx = sizeTotal.cy = 500;
    SetScrollSizes(MM_TEXT, sizeTotal);
    }
    //在对话框中创建view并移动到指定位置
    CCreateContext createContextL;
    createContextL.m_pNewViewClass = RUNTIME_CLASS(CELTestViewL);
    CWnd* pFrameWndL = this;
    pViewL = (CELTestViewL*)((CFrameWnd*)pFrameWndL)->CreateView(&createContextL);
    pViewL->ShowWindow(SW_SHOW);CRect rectL;
    GetWindowRect(&rectL);
    rectWnd = rectL;
    rectL.right *= 0.49;
    rectL.top   = rectL.bottom * 0.49;
    rectL.left += 18;
    rectL.bottom *= 0.9;pViewL->MoveWindow(rectL);
      

  4.   


    这样做试试
    把CELTestViewL的构造函数改为public
    定义一个指针CELTestViewL* m_pTestView;创建view、m_pTestView=new CELTestViewL();
    CRect rectL;
    GetClientRect(&rectL);
    rectL.right *= 0.49;
    rectL.top   = rectL.bottom * 0.49;
    rectL.left += 18;
    rectL.bottom *= 0.9;m_pTestView->Create(NULL, "TestView",  WS_VISIBLE|WS_BORDER,rectL, this, 1234)) 
    红色部分是窗口ID,自己指定
      

  5.   

    在对话框创建的view不会自动调用OnInitialUpdate(),所以创建完view后要自己来调用pViewL = (CELTestViewL*)((CFrameWnd*)pFrameWndL)->CreateView(&createContextL);   CSize sizeTotal;
        // TODO: calculate the total size of this view
        sizeTotal.cx = sizeTotal.cy = 500;
        SetScrollSizes(MM_TEXT, sizeTotal);    

    pViewL->ShowWindow(SW_SHOW);
      

  6.   

    SetScrollSizes(MM_TEXT, sizeTotal);   
    改为
    pViewL->SetScrollSizes(MM_TEXT, sizeTotal);