CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 1999
    Location
    Europe / Austria / Tirol
    Posts
    159

    Unexperienced in drawing, please help!

    Hy!

    In my CRichEditView I am drawing a coloured rectangle and a bitmap at the left side. I used GetRichEditCtrl().SetRect() to move the richedit output 40 pixels to the right, so the text appears where it should, and my rectangle and bitmaps are displayed correctly.

    But when I streamin text into the control, the view begins to flicker. (I do a ShowWindow(SW_HIDE) and ShowWindow(SW_SHOW) before and after the StreamIn function).
    So I tried to disable background deleting, which did not help. Then I set the color of the richedit control to the color of the rectangle, and, voila, the flickering was gone.
    But now the window behind the text is coloured, and not white.

    Here's my code:

    void CChatView::OnPaint()
    {
    if (inpaint)
    return;

    inpaint = TRUE;
    CRichEditView::OnPaint();

    CClientDC dc(this);

    //draw the logo
    BITMAP bm;
    CDC dcMem;
    VERIFY(m_pBmp->GetObject(sizeof(BITMAP), (LPVOID)&bm));
    dcMem.CreateCompatibleDC(NULL);
    CBitmap* pOldBitmap = dcMem.SelectObject(m_pBmp);
    dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &dcMem, 0, 0, SRCCOPY);
    dcMem.SelectObject(pOldBitmap);


    //get client rect, set sizes
    CRect rect_left;
    GetClientRect(&rect_left);
    rect_left.bottom += 1;
    rect_left.right = 40;
    rect_left.top = bm.bmHeight;

    //draw rectangle
    dc.FillSolidRect(&rect_left, RGB(255,102,0) );

    inpaint = FALSE;
    }

    What is wrong here?
    Robert


    Robert Rostek
    -=[tecxx@rrs.dhs.org]=-

  2. #2
    Join Date
    Aug 2000
    Location
    UK, Cambridge
    Posts
    79

    Re: Unexperienced in drawing, please help!

    I think the problem is that the Windows GDI Drawing functions are dead slow. The call to dc.FillSolidRect is the one that makes the flickering. What I suggest you do is the following:
    1) Create a rectangular bitmap of the colour you want to use as the solid rectangle.
    2)Override the CRichEditView::OnEraseBkgnd() function and blit (or stretchblt) the bitmap onto the left part of the pane.
    Hope this helps.
    Tom


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured