2012-02-10 44 views
0

我開始使用Overbyte組件,用來印地使用,但阻塞問題讓我找別的東西,所以我找到了ICS,但是在這個示例代碼:OverbyteICS HTTPAsync示例代碼:如何從列表框中刪除重複的url?

HTTPAsync

它的每一個環節都創造了新的HTTPCli組件內部列表框,但是當我改變代碼位:

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; 

當我把10個鏈接它有時會添加重複到列表框中,或者一個鏈接將其添加到列表框兩個相同的鏈接。 我怎樣才能解決它不顯示重複。我的想法是把它放在tstringlist裏面,並檢查重複並刪除它們。

是否有任何其他way.Thanks

回答

1

您可以檢查,看它是否添加它之前已經存在:

if something then 
    if ListBox1.Items.IndexOf(AHttpCli.URL) = -1 then 
    ListBox1.items.add(AHttpCli.URL); 
+0

感謝肯,我覺得自己像白癡不記住... 大回答:) – Daniel 2012-02-11 21:57:54