Link to home
Start Free TrialLog in
Avatar of JacekH
JacekHFlag for Poland

asked on

TOwnedCollection and RTTI editor no insert or delete

I have two classes derived from TOwnedCollection and TCollectionItem used as a Component. They're working ok, I can see items in ObjectInspector window and I can edit (add, delete, change properties) of collection items. What I want to do is blocking adding or removing items in RTTI editor (or from code).  Please, take a look at this code:

TMyCollection =  class (TOwnedCollection)
private
  function Add  :TCollectionItem;
  function Insert(const AIndex : Integer) : TCollectionItem;
protected
  function  GetItem (const AIndex : Integer) : TCollectionItem;
  procedure SetItem (const AIndex : Integer;
                    const AValue : TCollectionItem);

public
  constructor Create (const AOwner : TComponent);
  function FindItemID (const AID    : Integer) : TCollectionItem;
  property Items      [const AIndex : Integer] : TCollectionItem read
GetItem write SetItem;
end;

TTestComponent = class(TComponent)
     private
      FMyCollection: TMyCollection;
    procedure SetMyCollection(const Value: TMyCollection);
     public
      constructor Create(AOwner: TComponent); override;
      destructor Destroy; override;
     published
      property MyCollection: TMyCollection read FMyCollection; // here's my problem I think
   end;

It's an example only. The real code is used for many purposes - as components. One of them is creating a list (TOwnedCollection) of audio ports (TCollectionItem). When I create TOwnedCollection I also create as many TCollectionItems as waveOutGetNumDevs returns. I don't want to allow adding or removing new audio ports, just want to allow editing in RTTI editor ports activity, buffer size etc.  How can I do that?

Regards,
Jacek
Avatar of JacekH
JacekH
Flag of Poland image

ASKER

More points.... :)
ASKER CERTIFIED SOLUTION
Avatar of dinilud
dinilud
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JacekH

ASKER

Thank you.

Best regards,
Jacek