Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

other Screen Flickers while adding items to ListBox

Posted on 2001-09-06
5
Medium Priority
?
360 Views
Last Modified: 2010-04-06
the taskbar flickers while my program is adding items to the listbox. I already applied the lockwindowupdate to my program.

how can i stop the flickering?  thanks a lot.
0
Comment
Question by:JPDP
[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
5 Comments
 
LVL 6

Expert Comment

by:DrDelphi
ID: 6463006
Well, if you are adding a lot of things to the list at one time, you might consider adding them to an offscreen TStringlist first, and then assigning that to the listbox. For example:


procedure TForm1.FormCreate(Sender: TObject);
var loopint:integer;
begin
  for loopint:=0 to 1000 do //add 1000 items to the listbox
  begin
    listbox1.Items.add(inttostr(loopint));
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
var loopint:integer;
    lstItems:TstringList;
begin
  LstItems:=Tstringlist.create;
  LstItems.AddStrings(Listbox1.items);//asign the current items to the stringlist first
  for loopint:=0 to 1000 do
  begin
    lstitems.Add(inttostr(loopint+1000)); //and add 1000 more
  end;
  Listbox1.items:=lstItems;//assign the Stringlist to the listbox ... no flicker!
  LstItems.free;// free resources
  end;



Good luck!!
0
 
LVL 3

Accepted Solution

by:
Stefaan earned 100 total points
ID: 6463255
Hi,

Have you already tried using the BeginUpdate and EndUpdate ?

TheListBox.Items.BeginUpdate;

// now add your items

TheListBox.Items.EndUpdate;

Best regards,


Stefaan
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6463303
Stefaan is correct. I would advise *against* using LockWindowUpdate in this case.
0
 
LVL 1

Expert Comment

by:Dennis9
ID: 6463751
Hi.
This will help a lot against flicking, u should just set it in the oncreate of the form:
ListBox1.DoubleBuffered := true;

Dennis
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6466248
listening
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

670 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