[programming] Re: D1 TOutline Component

  • From: Erwin Dokter <edokter@xxxxxxx>
  • To: programming@xxxxxxxxxxxxx
  • Date: Sat, 18 Aug 2001 23:05:01 +0200

John wrote:
> 
> Well I finally got around to debugging my problem with Duplicate Directory
> names and files.  The issue is not neccessarily with TOutline or
> TStringList, the problem is with a for loop of mine, here is the problematic
> for loop:
> 
>          For I := 0 TO Fils.Count - 1 Do
>          Begin
>            Outline.AddChild(Level, Fils[I]);
>            Outline.Items[Outline.GetTextItem(Fils[I])].Data := TData.Create;
>            TData(Outline.Items[Outline.GetTextItem(Fils[I])].
>              Data).IsLast := I = Fils.Count - 1;
>            TData(Outline.Items[Outline.GetTextItem(Fils[I])].
>              Data).HasGlyph := False;
>          end;

Hi John,

I think the best solution would be to use the outline's index instead of
using GetTextItem:

  var
    Index: Integer;

  For I := 0 TO Fils.Count - 1 Do
  Begin
    Index := Outline.AddChild(Level, Fils[I]);
    Outline.Items[Index].Data := TData.Create;
    TData(Outline.Items[Index].Data).IsLast := I = Fils.Count - 1;
    TData(Outline.Items[Index].Data).HasGlyph := False;
  end;

This will always return the item you just created. Hope this helps...

-- Erwin Dokter
   mailto:edokter@xxxxxxx
   http://members.home.nl/edokter
To unsubscribe, send a message to programming-request@xxxxxxxxxxxxx with the 
words "unsubscribe"  (without quotes) in the subject feild.  OR visit 
//freelists.org/

Other related posts: