Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

other Screen Flickers while adding items to ListBox

Posted on 2001-09-06
5
Medium Priority
?
362 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

885 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