views:

153

answers:

1

Hi dudes,

I'm trying to do this:

   type
      TItemRec = record
        Sender    : TAction;
        OwnerPack : HModule;
        ChildForm : TForm;
      end;
      TRecList = TList<TItemRec>;

      THelperList = class helper for TRecList
        function FindSenderIndex(ASender: TAction): Int16;
      end;
   var
      MyObj : TRecList;

Where FindSenderIndex function (implementing it still) will return index of the item where ASender matchs with MyObj[i].Sender. But when compiling I get this error message: "E2086 Type 'TList<T>' is not yet completely defined"

What am I doing bad? Thanks in advance.

Pdta: May you give me some good examples about how to use Object Containers (TObjectList<T:class>=class(TList<T>))?

+4  A: 

This looks like a bug in the compiler. I'm able to reproduce this under Delphi 2010. Please report it in QC.

The workaround's simple enough, though. Declare

TRecList = class(TList<TItemRec>);

instead, and it works.

As for TObjectList<T>, it's exactly the same as TList<T> except that it will only accept objects, and it adds the OwnsObjects property. If OwnsObjects is set to True, then when you free the list, or call the Clear or Delete methods, it will free all the objects removed from the list.

Mason Wheeler