ListView flickering

  • Thread starter Thread starter kelvin.koogan
  • Start date Start date
K

kelvin.koogan

Using VS2005, C++, .NET

I have a ListView with OwnerDraw=true, Details view, that I am using
to display messages in real-time. Ideally I want to scroll down to the
bottom, i.e. most recent message, each time one is added.

However the control flickers horribly, much worse than the RichTextBox
which I'm using elsewhere.

I've tried various techniques, double-buffering, filtering out
WM_ERASEBKGND, but none of them seem to work.

Any suggestions for a way to prevent flickering?

TIA,
KK
 
Did you try using ListView.BeginUpdate and EndUpdate? Put your item
addition and scrolling calls between these two. Not sure how it
behaves with OwnerDraw, though.
 
Did you try using ListView.BeginUpdate and EndUpdate?  Put your item
addition and scrolling calls between these two.  Not sure how it
behaves with OwnerDraw, though.
--http://www.kynosarges.de

I haven't tried BeginUpdate and EndUpdate because all the postings
I've seen from other users say they don't work.

KK
 
I haven't tried BeginUpdate and EndUpdate because all the postings
I've seen from other users say they don't work.

I have no idea what postings you might be referring to. Of course
these calls work, in some way at least. They might not have the
effect you want in your specific scenario but you won't know that
until you try them.
 
However the control flickers horribly, much worse than the RichTextBox
which I'm using elsewhere.

I've tried various techniques, double-buffering, filtering out
WM_ERASEBKGND, but none of them seem to work.

Any suggestions for a way to prevent flickering?


Take a look at ControlStyles.Opaque, ControlStyles.DoubleBuffer,
ControlStyles.ResizeRedraw, etc.:

http://msdn2.microsoft.com/en-us/library/system.windows.forms.controlstyles(VS.71).aspx
Opaque
If true, the control is drawn opaque and the background is not painted.

If I remember correctly, setting the Opaque flag is the most important
thing. Otherwise the control paints a solid background, which undermines
all your double buffering efforts (i.e. the control will fill a solid
rectangle before you paint your stuff, and that causes the most terrible
flicker).

Without seeing your code, this is the best I can recommend.

Tom
 
Back
Top