Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. double buffering

double buffering

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aangerma
    wrote on last edited by
    #1

    Hello, I have an owner-draw listBox that while updating its flicks, I tried the solution of treating the event OnEraseBkgnd its didn't work, so I tried the other posibility - double buffering void CIconListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { pDC = CDC::FromHandle(lpDrawItemStruct->hDC); HDC memDC1 = CreateCompatibleDC(lpDrawItemStruct->hDC); HBITMAP hMemBmp = CreateCompatibleBitmap(lpDrawItemStruct->hDC, scrW, scrH); HBITMAP hOldBmp = (HBITMAP)SelectObject(memDC1, hMemBmp); CDC *memDC=CDC::FromHandle(memDC1); . . if(m_pImgClose) m_pImgClose->Draw(memDC,0,pt1,ILD_NORMAL); . . memDC->DrawText(line.word[1].str, -1, &rText, DT_LEFT); . . SetTextColor(memDC1,oldcolor); . . BitBlt(lpDrawItemStruct->hDC, 0, 0, scrW, scrH, memDC1, 0, 0, SRCCOPY); SelectObject(memDC1, hOldBmp); DeleteObject(hMemBmp); DeleteDC(memDC1); } for some resone its doing the background black instead of white as it was before the double buffer. if anyone know what is my problem ,I would be very greatfull for him.

    S 1 Reply Last reply
    0
    • A aangerma

      Hello, I have an owner-draw listBox that while updating its flicks, I tried the solution of treating the event OnEraseBkgnd its didn't work, so I tried the other posibility - double buffering void CIconListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { pDC = CDC::FromHandle(lpDrawItemStruct->hDC); HDC memDC1 = CreateCompatibleDC(lpDrawItemStruct->hDC); HBITMAP hMemBmp = CreateCompatibleBitmap(lpDrawItemStruct->hDC, scrW, scrH); HBITMAP hOldBmp = (HBITMAP)SelectObject(memDC1, hMemBmp); CDC *memDC=CDC::FromHandle(memDC1); . . if(m_pImgClose) m_pImgClose->Draw(memDC,0,pt1,ILD_NORMAL); . . memDC->DrawText(line.word[1].str, -1, &rText, DT_LEFT); . . SetTextColor(memDC1,oldcolor); . . BitBlt(lpDrawItemStruct->hDC, 0, 0, scrW, scrH, memDC1, 0, 0, SRCCOPY); SelectObject(memDC1, hOldBmp); DeleteObject(hMemBmp); DeleteDC(memDC1); } for some resone its doing the background black instead of white as it was before the double buffer. if anyone know what is my problem ,I would be very greatfull for him.

      S Offline
      S Offline
      Sauro Viti
      wrote on last edited by
      #2

      Before drawing on your memory device context, have you ever filled its background color? The CreateCompatibleBitmap produce a bitmap initially black, then you need to fill it with the color you want, e.g. using the CDC::FillSolidRect (MFC)[^] API.

      A 1 Reply Last reply
      0
      • S Sauro Viti

        Before drawing on your memory device context, have you ever filled its background color? The CreateCompatibleBitmap produce a bitmap initially black, then you need to fill it with the color you want, e.g. using the CDC::FillSolidRect (MFC)[^] API.

        A Offline
        A Offline
        aangerma
        wrote on last edited by
        #3

        thank you very much its solved my problem

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups