Solved

Avoid flicker when updating TListView

Posted on 2002-04-27
11
1,309 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
  • 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now