Solved

other Screen Flickers while adding items to ListBox

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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Suggested Courses
Course of the Month3 days, 21 hours left to enroll

630 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