Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 882271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:24:06+00:00 2026-05-15T12:24:06+00:00

Consider a plain Win32 dialog with listview control (in report mode) written in C++.

  • 0

Consider a plain Win32 dialog with listview control (in report mode) written in C++. Upon a certain event all items and all columns are deleted and new columns and items are created. Basically, as content changes, columns are automatically generated based on content.

When old items/columns are removed and new ones added, listview flickers like hell. I have tried WM_SETREDRAW and LockWindowUpdate() with no change to visual experience.

I have even set extended listview style LVS_EX_DOUBLEBUFFER and that didn’t help at all.

The parent dialog has WS_CLIPCHILDREN set.

Any suggestions how to make this work with as little flicker as possible? I am thinking of using two listviews, alternating visibility, using the hidden one as a back buffer but this sounds like an overkill. There must be an easy way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:24:07+00:00Added an answer on May 15, 2026 at 12:24 pm

    The default list control painting is pretty flawed. But there is a simple trick to implement your own double-buffering technique:

    CMyListCtrl::OnPaint()
    {
        CRect rcClient;
        GetClientRect(rcClient);
    
        CPaintDC dc(this);
        CDC dcMem;
        dcMem.CreateCompatibleDC(&dc);
    
        CBitmap bmMem;
        bmMem.CreateCompatibleBitmap(&dc, rcClient.Width(), rcClient.Height());
        CBitmap* pbmOld = dcMem.SelectObject(&bmMem);
    
        dcMem.FillSolidRect(rcClient, ::GetSysColor(COLOR_WINDOW));
    
        this->DefWindowProc(WM_PAINT, (WPARAM)dcMem.m_hDC, (LPARAM)0);
    
        dc.BitBlt(0,0,rcClient.Width(), rcClient.Height(), &dcMem, 0, 0, SRCCOPY);
        dcMem.SelectObject(pbmOld);
    
        CHeaderCtrl*    pCtrl = this->GetHeaderCtrl();
        if (::IsWindow(pCtrl->GetSafeHWnd())
        {
            CRect   aHeaderRect;
            pCtrl->GetClientRect(&aHeaderRect);
            pCtrl->RedrawWindow(&aHeaderRect);
        }
    }
    

    This will create a bitmap and then call the default window procedure to paint the list control into the bitmap and then blitting the contents of the bitmap into the paint DC.

    You should also add a handler for WM_ERASEBKGND:

    BOOL CMyListCtrl::OnEraseBkgnd(CDC* pDC)
    {
        return TRUE;
    }
    

    This will stop the control from always erasing the background before a redraw.
    You can optimize the OnPaint further if you add a member variable for the bitmap and only (re)create it when the size of the window changed (because always creating a bitmap may be costly depending on the size of the window).

    This should work pretty well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After having read Ian Boyd 's constructor series questions ( 1 , 2 ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.