Solved

other Screen Flickers while adding items to ListBox

Posted on 2001-09-06
5
351 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
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 25 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

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

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…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
A short film showing how OnPage and Connectwise integration works.

948 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

20 Experts available now in Live!

Get 1:1 Help Now