473,425 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,425 software developers and data experts.

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
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.

May 16 '06 #1
5 9500
_DD
On 15 May 2006 17:11:10 -0700, jt*************@Hotmail.com wrote:
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


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
May 16 '06 #2
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

<jt*************@Hotmail.com> wrote in message
news:11*********************@y43g2000cwc.googlegro ups.com...
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.

May 16 '06 #3
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

May 21 '06 #4
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?

May 21 '06 #5
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).

May 30 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Joaquin Grech | last post by:
Hi I did alot of research on this on the web and msdn and I couldn't find anything. I have a listview showing as a grid (table looking, with rows and columns and no images at all, only text)....
5
by: Phill | last post by:
I've got a Listview control (Detail mode) that I'm adding rows to on another thread from a DB query. The result is about 32,000 rows ans takes a while to finish. I'm adding the rows like this...
2
by: John Lee | last post by:
Hi, I have a windows application that uses the listview to display about 50 items in detailed view - 4 columns. The first column is static and other columns will be updated in 100-1000ms - it...
2
by: John Lee | last post by:
Thanks Jay for your response. I tried your code and it still flickering a lot. To demonstrate it, you can grab a listview, create 3 columns - name, value, timestamp, in form_load event to add 50...
1
by: Lou | last post by:
How do I keep a control from flickering while its updating? -Lou
0
by: James | last post by:
Hi all, I have made a derived Listview which can accept the controls as items in it. Controls that we are using are Buttons in each row and implemented Grouping with the help of controls(label on...
0
by: James | last post by:
Hi all, I have made a derived Listview in C# .net 1.1 framework, which can accept the controls as items in it. Controls that we are using are Buttons in each row and implemented Grouping with...
4
by: kelvin.koogan | last post by:
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...
0
by: IanWright | last post by:
I'm trying to change the cursor that appears on a standard ListView when the cursor appears over an item. However I am getting a flickering effect as the mouse is changed to a finger cursor, and then...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.