type
TListViewThread = class(TThread)
private
FIndex: Integer;
FListView: TListView;
proceduredo
AddItem;
protected
procedure Execute;
override;
public
constructor Create(AListView: TListView);
end;
{ TListViewThread }
constructor TListViewThread.Create(AListView: TListView);
begin
FListView := AListView;
FreeOnTerminate := True;
inherited Create(False);
end;
procedure TListViewThread.DoAddItem;
begin
Inc(FIndex);
with FListView.Items.Adddo
begin
Caption := IntToStr(FIndex);
SubItems.Add('Item' + IntToStr(FIndex));
SubItems.Add('Memo' + IntToStr(FIndex));
end;
Application.ProcessMessages;
end;
procedure TListViewThread.Execute;
var
I, K: Integer;
begin
I := 1;
while not Terminated and (I <
1000)do
begin
for K := 1 to 20do
Synchronize(DoAddItem);
Sleep(1000);
Inc(I);
end;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
TListViewThread.Create(ListView1);
end;