在输出文本时想只重会当前修改的内容,但是没想到其他行的文本都不见了,只剩下当前行,怎么回事??

解决方案 »

  1.   

    //Draw text
    if (bRedrawWhole == TRUE) { //we need to redraw the whole view
    //construct text rect for drawing based on the scroll position
    rectText         = rectClient; 
    rectText.right  += ScrolledPos.x;
    rectText.top    += ScrolledPos.y;
    rectText.bottom += ScrolledPos.y;
    for (i = nStartLine; i <= nEndLine; i++) {
    sli = pLines->GetAt(i);
    sTmp.Format("%s" , sli.m_pcLine);
    nLineHeight = pDC->DrawText(sTmp , -1 , &rectText, DT_TOP | DT_NOPREFIX | DT_SINGLELINE | DT_EXPANDTABS);
    rectText.top += nLineHeight;
    }
    } else { // we need only to redraw the current 2 lines
    //construct text rect for drawing based on the scroll position
    rectText         = rectClient; 
    rectText.right  += ScrolledPos.x;
    rectText.top    += ScrolledPos.y + (nCurrentLine - nStartLine) * nLineHeight;
    rectText.bottom += ScrolledPos.y + (nCurrentLine - nStartLine) * nLineHeight;
    for (i = 0; i <= 1; i++) {
    sli = pLines->GetAt(nCurrentLine + i);
    sTmp.Format("%s" , sli.m_pcLine);
    nLineHeight = pDC->DrawText(sTmp , -1 , &rectText, DT_TOP | DT_NOPREFIX | DT_SINGLELINE | DT_EXPANDTABS);
    //pDC->TabbedTextOut(rectText.left, rectClient.top, sTmp, 0, NULL, 0);
    rectText.top += nLineHeight;
    }
    bRedrawWhole = TRUE;
    }
      

  2.   

    for (i = nStartLine; i <= nEndLine; i++) {
    sli = pLines->GetAt(i);
    sTmp.Format("%s" , sli.m_pcLine);
    nLineHeight = pDC->DrawText(sTmp , -1 , &rectText, DT_TOP | DT_NOPREFIX | DT_SINGLELINE | DT_EXPANDTABS);
    rectText.top += nLineHeight;
    }——是不是在rectText.top += nLineHeight;这句后面少了
    rectText.bottom += nLineHeight;我觉得应该是:
    for (i = nStartLine; i <= nEndLine; i++) {
    sli = pLines->GetAt(i);
    sTmp.Format("%s" , sli.m_pcLine);
    nLineHeight = pDC->DrawText(sTmp , -1 , &rectText, DT_TOP | DT_NOPREFIX | DT_SINGLELINE | DT_EXPANDTABS);
    rectText.top += nLineHeight;
                       rectText.bottom += nLineHeight;

    }
      

  3.   

    楼上:
    不用,实际上rectText只定义了顶部坐标就可以了。其实我主要是想解决连续输入是的view的闪烁问题,本来想先在内存设备里画好,然后在输出倒屏幕设备,发现这样闪烁问题更严重,所以想能否只重写一行或两行。
      

  4.   

    你的DrawText是在哪儿调用的啊,是不是位置不对啊。
      

  5.   

    在VIEW 的 OnDraw(CDC *pDC)里自动调用的