[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Avoid flicker when updating TListView

Posted on 2002-04-27
11
Medium Priority
?
1,366 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

650 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