Connecting Tech Pros Worldwide Help | Site Map

flickering listview

  #1  
Old May 16th, 2006, 01:15 AM
jtalbot_vizible@Hotmail.com
Guest
 
Posts: n/a
I was looking at the code on codeproject to solve my listview
flickering issue. All the references to functions in the rest of my
post refer to that code. It's available at
http://www.codeproject.com/cs/miscct...58&msg=1488858

That code didn't solve my problem. I have a ListView (in Details mode)
with about 70 rows and 12 columns. It's a stock ticker kind of app.
When it first starts, each subitems are updated once as data is
received from the server. During that time flickering is so bad, it's
probably epilepsy seisure-inducing. The update messages are coming from
a library at random intervals.

After the initial global update, individual subitems are updated fairly
frequently -- I'd say about 20 subitems per second. The updating for
each subitem includes font color changes, background color changes, and
subitem text changes (no rows/columns are added or removed). Even
during those updates it's still pretty obvious that the background is
being repainted -- it still flickers.

Stepping through the code, it seems like the call to this.Update() in
the function updateItem() returns right away. By the time the WndProc
function gets called, updateItem() has already re-setted the updating
flag to false.

To test out that theory, I commented the line in UpdateItem() that sets
updating to false, rather set it to false in the WndProc function, as
follow:

protected override void WndProc(ref Message messg)
{
if (myUpdating)
{
myUpdating = false;
if ((int)WM.WM_ERASEBKGND == messg.Msg)
{
...
}
...
}
...
}

This made no difference whatsoever. (still don't know why)

I then tried ALWAYS cancelling WM_ERASEBKGND messages, and that worked
(well, I got flicker-free updates (it was beautiful I tells ya!), but
of course scrolling, resizing, etc. didn't work properly).

The library I'm using to get the stock market data is multi-threaded. I
came to the conclusion that a different thread calls the updateItem()
function than what calls WndProc(). I didn't think that was possible.
The class that receives the messages from the 3rd party library
implements ISynchronizeInvoke, and the library properly calls
InvokeRequired, etc, which I thought would force all my code to be
called by the same thread. Apparently not.

Anyway, I suppose if I had a synchronous version of Control.Update()
(the function being called in UpdateItem() between setting the update
flag to true and setting it to false) then everything would be cool. Is
there such a thing?

If anybody has any suggestion on how to solve this, pls let me know :)
I suppose extending the codeproject code with a list of items to update
would do it, but I'm hoping there's something simpler that I'm missing.

  #2  
Old May 16th, 2006, 06:25 AM
_DD
Guest
 
Posts: n/a

re: flickering listview


On 15 May 2006 17:11:10 -0700, jtalbot_vizible@Hotmail.com wrote:
[color=blue]
>I was looking at the code on codeproject to solve my listview
>flickering issue. All the references to functions in the rest of my
>post refer to that code. It's available at
>http://www.codeproject.com/cs/miscct...58&msg=1488858[/color]

I was just looking at a GroupBox control on CodeProject today, and it
had some comments about anti-flicker. Dug it up again just in case
it's something you haven't tried. Also, I usually refresh controls on
higher granularity.

Group Box: http://www.codeproject.com/useritems/grouper.asp
  #3  
Old May 16th, 2006, 11:05 AM
Lee Alexander
Guest
 
Posts: n/a

re: flickering listview


I had a similar issue. I derived from ListView and in the constructor set
the property 'DoubleBuffered' to true, then i used the modified class in the
originals place. It seemed to do the trick for me...

Regards
Lee

<jtalbot_vizible@Hotmail.com> wrote in message
news:1147738270.029465.27120@y43g2000cwc.googlegro ups.com...[color=blue]
>I was looking at the code on codeproject to solve my listview
> flickering issue. All the references to functions in the rest of my
> post refer to that code. It's available at
> http://www.codeproject.com/cs/miscct...58&msg=1488858
>
> That code didn't solve my problem. I have a ListView (in Details mode)
> with about 70 rows and 12 columns. It's a stock ticker kind of app.
> When it first starts, each subitems are updated once as data is
> received from the server. During that time flickering is so bad, it's
> probably epilepsy seisure-inducing. The update messages are coming from
> a library at random intervals.
>
> After the initial global update, individual subitems are updated fairly
> frequently -- I'd say about 20 subitems per second. The updating for
> each subitem includes font color changes, background color changes, and
> subitem text changes (no rows/columns are added or removed). Even
> during those updates it's still pretty obvious that the background is
> being repainted -- it still flickers.
>
> Stepping through the code, it seems like the call to this.Update() in
> the function updateItem() returns right away. By the time the WndProc
> function gets called, updateItem() has already re-setted the updating
> flag to false.
>
> To test out that theory, I commented the line in UpdateItem() that sets
> updating to false, rather set it to false in the WndProc function, as
> follow:
>
> protected override void WndProc(ref Message messg)
> {
> if (myUpdating)
> {
> myUpdating = false;
> if ((int)WM.WM_ERASEBKGND == messg.Msg)
> {
> ...
> }
> ...
> }
> ...
> }
>
> This made no difference whatsoever. (still don't know why)
>
> I then tried ALWAYS cancelling WM_ERASEBKGND messages, and that worked
> (well, I got flicker-free updates (it was beautiful I tells ya!), but
> of course scrolling, resizing, etc. didn't work properly).
>
> The library I'm using to get the stock market data is multi-threaded. I
> came to the conclusion that a different thread calls the updateItem()
> function than what calls WndProc(). I didn't think that was possible.
> The class that receives the messages from the 3rd party library
> implements ISynchronizeInvoke, and the library properly calls
> InvokeRequired, etc, which I thought would force all my code to be
> called by the same thread. Apparently not.
>
> Anyway, I suppose if I had a synchronous version of Control.Update()
> (the function being called in UpdateItem() between setting the update
> flag to true and setting it to false) then everything would be cool. Is
> there such a thing?
>
> If anybody has any suggestion on how to solve this, pls let me know :)
> I suppose extending the codeproject code with a list of items to update
> would do it, but I'm hoping there's something simpler that I'm missing.
>[/color]


  #4  
Old May 21st, 2006, 09:05 PM
jtalbot_vizible@Hotmail.com
Guest
 
Posts: n/a

re: flickering listview


Thanks Lee & _DD for your replies. Unfortunately neither suggestion
seemed to solve the problem. I've put some sample code at this URI.
It's a short example that implemented both of your suggestion (together
with a suggestion from this blog:
http://geekswithblogs.net/cpound/arc...?Pending=true),
to no avail... :(

http://www.dgp.toronto.edu/~jtalbot/...ubleBuffer.zip

  #5  
Old May 21st, 2006, 10:35 PM
jtalbot_vizible@Hotmail.com
Guest
 
Posts: n/a

re: flickering listview


Oh, I found some listview control implementation by glacial:
http://www.glacialcomponents.com/ProdDetail/glv.aspx

I substituted their listview control in my test app (see previous
message for URI), and there is no flickering *at all*. Does anyone know
how they did it?

  #6  
Old May 30th, 2006, 06:25 PM
jtalbot_vizible@Hotmail.com
Guest
 
Posts: n/a

re: flickering listview


I switched to using a DataGrid instead of a ListView. The window
doesn't flicker at all, and performance appears to be much better too.

However, there is a new issue: when the app window is not in the
foreground (I haven't tried minimizing), the *rest* of the screen
flickers: desktop icons, other applications, etc. <sigh>

Is this a known issue? (a bit of googling didn't yield anything yet).

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listview flickering problem John Lee answers 2 November 16th, 2005 04:01 PM
Listview update flickering problem John Lee answers 2 November 16th, 2005 03:57 PM
ListView Unbearable C# Learner answers 9 November 15th, 2005 10:46 PM
how to avoid flickering in listview? Joaquin Grech answers 6 November 15th, 2005 02:45 PM