From: keeper@mindspring.com (Mark Johnson)
Subject: Re: [delphi] New Components and Property tStrings
Date: Tue, 11 Jul 1995 17:57:58 -0500

>How do I access other components in my application from within
>[my Base] component?

The Components[] list property exists in all descendants of TComponent
and is used to store references to any owned components.  When one
calls "mycomponent := TSomeComponent.Create(aComponent)", mycomponent
is placed in aComponent's Components[] list.  In most cases, the form
is specified as a component's owner in the Create method, in which case
the component is placed in the form's Components[] list.

The FindComponent() method (mentioned elsewhere) only searches the current
component's Components[] list.  If the object you want to find is owned
by a different component, you will have to scan the other component's
list.

Depending on how you create your Base and other components, you may have
to implement a recursive search algorithm that starts at the top of the
ownership tree (probably with the form), and then descends into the tree,
searching the Components[] list of each component it finds until the desired
object is reached.

A nice alternative is just to always specify your Base component as the
owner of all your other sub-components when you create them.  Then your
search of the Base component's Components[] list should work.

Hope this helps.
--Mark Johnson
______________________________________________________________________________
 Mark R. Johnson       _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
 Atlanta, GA USA       _/  http://www.mindspring.com/~cityzoo/cityzoo.html  _/
 keeper@mindspring.com _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
