flickering listview

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jtalbot_vizible@Hotmail.com

    #1

    flickering listview

    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


    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_ERA SEBKGND == 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 ISynchronizeInv oke, 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.

  • _DD

    #2
    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

    Comment

    • Lee Alexander

      #3
      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_vizibl e@Hotmail.com> wrote in message
      news:1147738270 .029465.27120@y 43g2000cwc.goog legroups.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_ERA SEBKGND == 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 ISynchronizeInv oke, 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]


      Comment

      • jtalbot_vizible@Hotmail.com

        #4
        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... :(



        Comment

        • jtalbot_vizible@Hotmail.com

          #5
          Re: flickering listview

          Oh, I found some listview control implementation by glacial:


          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?

          Comment

          • jtalbot_vizible@Hotmail.com

            #6
            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).

            Comment

            Working...