I started using Overbyte components , used to use Indy but blocking issue made me look for something else , so I found ICS , but in this example code:
It creates new HTTPCli component for every link inside listbox , but when I change code a bit:
procedure THttpAsyForm.HttpCli1DocData(Sender: TObject; Buffer: Pointer;
Len: Integer);
var
AHttpCli : THttpCli;
begin
if not DataCheckBox.Checked then
Exit;
AHttpCli := Sender as THttpCli;
{ Display a message stating that data is available }
DisplayMemo.Lines.Add('Item ' + IntToStr(AHttpCli.Tag) + ' Data');
{ We could display the data, but it use a huge space in the display }
DisplayMemo.Lines.Add(StrPas(Buffer));
if something then <--- CODE I ADDED
ListBox1.items.add(AHttpCli.URL); <--- CODE I ADDED
{ We could also store the data somewhere (with the help of OnDocBegin }
{ and OnDocEnd events. Or using the RcvdStream property. }
end;
When I put 10 links it sometimes adds duplicates to listbox , or with one link it adds two same links to listbox .
How can I fix it to not show duplicates.My idea was to put it inside tstringlist and check for duplicates and remove them.
Is there any other way.Thanks
You can check to see if it already exists before adding it: