Board index » delphi » Creating a COM object to hold COM objects

Creating a COM object to hold COM objects

I have created a COM object called "player" (in process) that
contains properties for a ball player. I want to create a COM object
called "players" that is a collection of "player" objects.

What kind of property will store multiple "player" objects in the
"players" collection?

How do I populate the "players" collection with "player" objects?

Any help is greatly appreciated.

Scott Wheeler

 

Re:Creating a COM object to hold COM objects


Inside your COM object TPlayers, simply declare the appropriate number
of IPlayer interfaces (11??). I hope the following code is relevant to
your question. If you need an indeterminate number of IPlayer Interfaces
you could use a TList to store them (but be careful with reference
counting in that case).

Steve

Type TPlayers = class(TAutoObject, IPlayers)
private
    FirstBase : IPlayer;
    SecondBase : IPlayer;
...
protected
    //create these interfaces in the init section
    procedure Initialize; override;
end;
...
procedure TPlayers.Initialize;
begin
    inherited Initialize;
    FirstBase := coPlayer.create;
    SecondBase := coPlayer.create;
...
end;

Quote
IIS wrote:
> I have created a COM object called "player" (in process) that
> contains properties for a ball player. I want to create a COM object
> called "players" that is a collection of "player" objects.

> What kind of property will store multiple "player" objects in the
> "players" collection?

> How do I populate the "players" collection with "player" objects?

> Any help is greatly appreciated.

> Scott Wheeler

Re:Creating a COM object to hold COM objects


Thank you very much!

Steve Midgley <steve@abomb_anti.spam.com> wrote in article
<35A503C1.1ADEAEE2@abomb_anti.spam.com>...

Quote
> Inside your COM object TPlayers, simply declare the appropriate
number
> of IPlayer interfaces (11??). I hope the following code is relevant
to
> your question. If you need an indeterminate number of IPlayer
Interfaces
> you could use a TList to store them (but be careful with reference
> counting in that case).

> Steve

> Type TPlayers = class(TAutoObject, IPlayers)
> private
>     FirstBase : IPlayer;
>     SecondBase : IPlayer;
> ...
> protected
>     //create these interfaces in the init section
>     procedure Initialize; override;
> end;
> ...
> procedure TPlayers.Initialize;
> begin
>     inherited Initialize;
>     FirstBase := coPlayer.create;
>     SecondBase := coPlayer.create;
> ...
> end;

Other Threads