Link to home
Create AccountLog 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
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of JacekH

ASKER

Thank you.

Best regards,
Jacek