Recent

Author Topic: FPC 3.2.2 - Components[Index: Integer] - don't work in Delphi mode  (Read 384 times)

paule32

  • Hero Member
  • *****
  • Posts: 645
  • One in all. But, not all in one.
Hello,
on implementing my own TComponent class, I stuck into a problem...
I can not use properties like: property Components[I: Integer]: TComponent
in {$mode delphi}

So, my Question is: how is it possible to Count the Elements ?

Code: Pascal  [Select][+][-]
  1. type
  2.   TComponent = class(TPersistent)
  3.   private
  4.     FOwner: TComponent;
  5.     FTag: NativeInt;
  6.   protected
  7.     function GetComponent: TComponent;
  8.     function GetComponentCount: Integer;
  9.     function GetComponentIndex: Integer;
  10.    
  11.     procedure SetComponentIndex(AValue: Integer);
  12.   public
  13.     constructor Create;
  14.     destructor Destroy; override;
  15.   published
  16.     property ComponentCount: Integer read GetComponentCount;
  17.     property ComponentIndex: Integer read GetComponentIndex write SetComponentIndex;
  18.     property Components[I: Integer]: TComponent read GetComponent;  // in this Line
  19.     property Owner: TComponent read FOwner;
  20.     property Tag: NativeInt read FTag write FTag default 0;
  21.   end;
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

Awkward

  • Full Member
  • ***
  • Posts: 154
Re: FPC 3.2.2 - Components[Index: Integer] - don't work in Delphi mode
« Reply #1 on: May 20, 2025, 03:58:47 pm »
You must define GetComponent function with index argument, like
function GetComponent(i:integer): TComponent;

 

TinyPortal © 2005-2018