Felipe Monteiro de Carvalho wrote:
Hello,

I was implementing TMenu for Qt, when I got a little confused by
component arrays.

On the file menu.inc I see this:

procedure TMenu.CreateHandle;
var i: integer;
begin
 FItems.Handle := TWSMenuClass(WidgetSetClass).CreateHandle(Self);
 // initiate creation of subitems
// Note: FItems is a TMenuItem. Using HandleNeeded will create all subitems.
 for i:=0 to Items.Count-1 do
   if Items[i].Visible then
     Items[i].HandleNeeded;
end;

And here is how Items is declared on this class:

   FItems: TMenuItem;
..............
   property Items: TMenuItem read FItems;

My doubts are:

1 ) Can I just take a property and use it as an array like that??

No, you cant. Not just any property.

Shouldn't that property be declared like this:

   property Items[Index: Integer]: TMenuItem read FItems;

TMenuItem has a default Items[] property.
So the code actually looks like:

Items.Items[i]

Since the second Items is default you may leave that one out.

2) And if it was declared like above, shouldn't FItems be an array of
TMenuItem ?

Are TComponent descendents naturally arrayable or something like that?

No.



Marc

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to