[lazarus] designer.inc file error
Michael A. Hess
mhess at miraclec.com
Wed Mar 22 11:10:40 EST 2000
Marc Weustink wrote:
> Since TCustomForm.IsControl is a protected member of TCustomForm it
> can be accessed.
Correct. TCustomForm can access the protected member. This means that
TCustomForm can access the protected member from inside one of its OWN
> That the protected member isn't declared in TCustomForm is another
> point, but it is still a protected member. The doc's don't say where
> the member should be declared.
Sure they do. The docs say, "members of a Protected section are also
accessible to descendent types, even if they are implemented in other
modules". In other words protected members in a class are available
outside of a unit if the class is a descendent. If it isn't a descendent
then the member is visible in the unit.
> Besides that this is how Delphi implemented it, so it should be
> possible in de delphi mode (I couldn't check it since we have other
> problems in delphi mode).
No I'm afraid not. The definition as indicated in the FPC docs and the
way it is working is exactly the way Delphi defines it and how Delphi
works. Following is the definition as it is found in the Delphi 4
documentation. The wording is different but it says the same thing.
A private member is invisible outside of the unit or program where its
class is declared. In other words, a private method cannot be called
from another module, and a private field or property cannot be read or
written to from another module. By placing related class declarations in
the same module, you can give the classes access to one anothers
private members without making those members more widely accessible.
A protected member is visible anywhere in the module where its class is
declared and from any descendant class, regardless of the module where
the descendant class appears. In other words, a protected method can be
called, and a protected field or property read or written to, from the
definition of any method belonging to a class that descends from the one
where the protected member is declared. Members that are intended for
use only in the implementation of derived classes are usually protected.
A public member is visible wherever its class can be referenced.
Note the last line of protected. "Members that are intended for use only
in the implementation of derived classes are usually protected." It can
only be used implementation of derived classes not from another class
that happens to be defined in the same unit.
> Or we have to declare thing more public, or we heve to put units
> together. I don't like both of them.
You just need to declare a property in the TCustomForm unit as public
that accesses the IsControl member. You do not need to modify the
TControl class at all.
==== Programming my first best destiny! ====
Michael A. Hess Miracle Concepts, Inc.
mhess at miraclec.com http://www.miraclec.com
More information about the Lazarus