[lazarus] designer.inc file error

Michael A. Hess mhess at miraclec.com
Tue Mar 21 20:57:53 EST 2000


Marc Weustink wrote:
> 
> > Protected  - Is the same as Private, except that the members of a
> >              Protected section are also accessible to descendent
> >              types, even if they are implemented in other modules.
> 
> Then I don't understand where the compiler is complaining about, since
> the protected member we are accessing is a member of a class which is
> defined in the same module.

No that isn't correct (see below)

> If protected is the same as private (only more visible) then also
> counts that protected members are visible outside the class, which
> seems not the case now.

No that is the case.
 
What is causing the problem is the method trying to access

     FCustomControl.IsControl;

The FCustomerControl variable is defined in the TDesigner class found in
the Forms unit.

FCustomControl is defined as

     FCustomControl = TCustomForm

TCustomForm is also defined in and part of the Forms unit.

However TCustomForm is a deriviative of TWinControl

     TCustomForm - class (TWinControl)

This is defined in and part of the Controls unit.

Then in the controls unit TWinControl comes from TControl which is where
the method IsControl is actually defined as "protected".

You are attempting to access a protected unit in a class from a
different unit. If you note the definition of protected says that, 

    "members of a Protected section are also accessible to descendent
     types, even if they are implemented in other modules"

In this case TCustomForm can access it's own protected member even
though it is located in a different unit BUT TDesigner which is not a
descendent can't access a protected member of TCustomForm which it
inherited from a different unit.

Got that.   :-)

If TDesigner and TCustomForm where located in the controls unit then
this would work fine. In this case a public member is required in the
TCustomForm class to allow TDesigner access.

-- 
==== Programming my first best destiny! ====

Michael A. Hess      Miracle Concepts, Inc.
mhess at miraclec.com   http://www.miraclec.com






More information about the Lazarus mailing list