473,787 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

May 16 '06 #1
5 9525
_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******** *************@y 43g2000cwc.goog legroups.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_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.

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
8868
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). I get the information to display on the listview from the network and I add items often and stuff. But more than adding items, what worries me is the step of modifying items.
5
4509
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 : lv.Items.Add( lvi ); It seems the entire control is redrawing even though usually the new rows being added are not visible. I don't remember this being the case in Win32. Anyway w/ all the flickering going on the LV control is too
2
8615
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 looks awful when it's running - flickering too much!!! Anyone know how to solve this flickering problem? or how should I deal with this issue? I see some other C++ app can display more than 100 items without any flickering in such as speed. Can...
2
2530
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 items into that listview as Item1 - Item49, add a timer to your windows form, set the timer interval to 100 ms, in the event handler, add the code to update the value and timestamp Random r = new Random(); listView1.BeginUpdate();
1
1426
by: Lou | last post by:
How do I keep a control from flickering while its updating? -Lou
0
1192
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 panel) . Coz Inbuilt listview Grouping not supported in OS like window 98. Although I had used Double buffering (SetStyle(ControlStyles.DoubleBuffer, true); .. in my Listview) but still the listview flickers much when we scroll its items. ...
0
1598
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 the help of controls(label on panel) . Coz Inbuilt listview Grouping not supported in OS like window 98. Although I had used Double buffering (SetStyle(ControlStyles.DoubleBuffer, true); .. in my Listview) but still the listview flickers much...
4
1716
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 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
0
2006
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 back to what I asked it to be. I'm trying to isolate this flicker/changing to the hand cursor but can't figure out where it's occuring or how to stop it. To replicate this... 1) Create a form with a ListView on it. 2) Add an image list and...
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10169
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.