Solved

Avoid flicker when updating TListView

Posted on 2002-04-27
11
1,318 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 10 Seattle Dataset Actions 5 79
Delphi with SQL Natvie Client 15 86
FMX enumerated colours 2 84
how to change, disabled button color FMX ? 1 18
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

28 Experts available now in Live!

Get 1:1 Help Now