Re: Disable TListBox Redraw...



On 27 Jul 2005 13:18:17 -0700, alanglloyd@xxxxxxx wrote:

>TStrings.BeginUpdate / TStrings.EndUpdate surrounding your code.
>
>or LockWindowUpdate(MyListbox.Handle) / LockWindowUpdate(0) surrounding
>your code.

LockWindowUpdate is a bit iffy - only one window can be locked.

Here is another method:

procedure TForm1.Button1Click(Sender: TObject);
Var
L9 :Integer;
begin
ListBox1.Perform( WM_SETREDRAW, Integer(False), 0 );
For L9 := 1 To 10 Do
ListBox1.Items.Add( IntToStr( L9 ) );
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
ListBox1.Perform( WM_SETREDRAW, Integer(True), 0 );
//ListBox1.Refresh; {not needed}
end;

I'm not too happy about the typecasting of True and False
.


Quantcast