在视图类的OnDraw()函数中使用TextOut()逐行输出文字,放大窗口时就可以看到很明显的闪烁,我看ms word就不会,用的什么技术?不会也是先输出到内存吧?请帮帮我!

解决方案 »

  1.   

    用内存DC
    CreateCompatiblDC创建一个内存dc
    然后在内存dc中textout
    最后再用bitblt拷贝到显示的dc中
      

  2.   

    具体能否来点代码?
    CRect ClientRect;
    GetClientRect(&ClientRect);
    CDC memDC;
    memDC.CreateCompatibleDC(pDC);
    CFont * oldFont=memDC.SelectObject(&m_OutFont);
    m_screenPos=0;
    for(stringlist::iterator pos=pDoc->m_ChatInfoLog.begin();pos != pDoc->m_ChatInfoLog.end();++pos)
    {
    memDC.TextOut(10,m_screenPos*12,(*pos).c_str());
    ++m_screenPos;
    }
    memDC.SelectObject(oldFont);
    pDC->BitBlt(0,0,ClientRect.Width(),ClientRect.Height(),&memDC,0,0,SRCCOPY);
    为什么不行,没有显示出来!
      

  3.   

    When a memory device context is created, GDI automatically selects a 1-by-1 monochrome stock bitmap for it. GDI output functions can be used with a memory device context only if a bitmap has been created and selected into that context.你必须首先选择一个bitmap到内存dc用CreateCompitableBitmap
    CBitmap bmp;
    bmp.CreateCompatibleBitmap(pDC, ClientRect.Width(), ClientRect.Height());
    HGDIOBJ hOldBmp = memDC.SelectObject(bmp); memDC.FillSolidRect(ClientRect, RGB(255, 255, 255));
      

  4.   

    晕啊,谢谢,原来要OnEraseBkgnd(CDC* pDC)中返回"真"就行了。