Solved

Avoid flicker when updating TListView

Posted on 2002-04-27
11
1,339 Views
Last Modified: 2012-08-14
I have a TListView with a small number of items that I however need to update a couple of times every second. When I'm doing this I get an annoying flicker. This disappears if I set DoubleBuffering to true but then everyting seems to be slowed down instead. For example, moving the window or selecting rows feels like walking around in glue... :-/ Anyone know of a way to avoid flickering without slowing down the application? Thanks!
0
Comment
Question by:jonassondaniel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6973586
listview1.items.beginUpdate;
try
  //do your update
finally
  listview1.items.endUpdate;
end;

meikl ;-)

0
 

Author Comment

by:jonassondaniel
ID: 6973593
I'm updating a couple of times every second.
0
 

Author Comment

by:jonassondaniel
ID: 6973620
I'm updating a couple of times every second.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 6973626
doesn't matter,
it will speed up
your update mostly flickree

from the delphi help

Prevents updating of the list view until the EndUpdate method is called.

procedure BeginUpdate;

Description

Call BeginUpdate before making multiple changes to the list of items. When all changes are complete, call EndUpdate so that the changes can be reflected on screen. BeginUpdate and EndUpdate prevent excessive redraws and speed processing time when new items are added, deleted, or inserted.

meikl ;-)
0
 

Author Comment

by:jonassondaniel
ID: 6973643
Before posting things like this you might want to try it or at least make sure what you're talking about...
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6973673
Before posting comments like this above, you might want to try to show/explain better your needs ...

(i know, what i'm talking about)
0
 
LVL 17

Accepted Solution

by:
inthe earned 200 total points
ID: 6973678
>>Before posting things like this you might want to try it or at least make sure what you're talking about...

bit rude ..


i agree with meikl,the problem is your updating continuly a couple of times per second doinjg mouse selections on it.doublebuffered uses quite a bit more memory and processing power so it will slow the listview down a bit.

maybe you should use a virtual control instead like mike virtual treeview(can act same as listview):

http://www.lischke-online.de/VirtualTreeview.html

0
 
LVL 17

Expert Comment

by:inthe
ID: 6973684
only other idea lock the window from painting till you want it to paint(from teamb):

LockControl(listview1.parent,True);
  try
    // do your thing
  finally
    LockControl(listview1.parent,False);
  end;


  procedure LockControl(c: TWinControl; lock: boolean);
  begin
    if (c=nil) or (c.Handle=0) then exit;

    if lock then SendMessage(c.Handle,WM_SETREDRAW,0,0)
    else begin
      SendMessage(c.Handle,WM_SETREDRAW,1,0);
      RedrawWindow(c.Handle,nil,0,
        RDW_ERASE or RDW_FRAME or RDW_INVALIDATE or RDW_ALLCHILDREN);
    end;
  end;
 
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6973722
updating a listview more than once a second is kinda um .. stoopid ?
if you really gotta do it then use DoubleBuffered
but as it was already said it uses twice the memory and is a bit slower :)
and BeginUpdate EndUpdate helps a lot if you update more than one item

using DoubleBuffered:=true and Begin/EndUpdate will get you the best visual experience with TListView

lischkes VirtualTreeView is also one great piece of a component :)
but you have to write lots of stuff yourself
0
 

Author Comment

by:jonassondaniel
ID: 6973794
The Virtual Treeview component was gold! Thanks!

And sorry for my previous grumpy comment... It was the consequence of hours of ListView fiddling ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6974773
>sorry for my previous grumpy comment
is ok
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question