Re: Event handlers...
- From: "alanglloyd@xxxxxxx" <alanglloyd@xxxxxxx>
- Date: 26 Jan 2006 22:46:37 -0800
A class is defined by an entry in the "type" clause in your code.
Something which starts with ...
TSomeObject = class(TSomeOtherObject) ...
Any the headers of any methods are declared in this declaration by
"procedure DoThis(" or "function GetThat(". Later on in the unit the
code in the method is declared. For that method code to be associated
by the compiler with the type declaration, it must have the type quoted
in the method code header. So code for the methods has the class name
as a prefix in that header eg ...
procedure TSomeObject.DoThis(...
.... and it is this classname prefix which is missing from your code and
so upsetting the compiler.
Methods are called differently from general procedures & functions. An
extra parameter named Self is passed to a method. This parameter is a
reference (OK - a pointer for people talking dirty) to the instance of
the class which called the method. For the DoSomething method called by
an instance of TSomeObject named MyObject it would be a reference to
MyObject. This allows any method to know which particular object is
calling it.
All _methods_ have _one_ chunk of code for _all_ instances of the
object. _Separate_ chunks of memory hold _data_ (property and
variables) for _each_ instance of the object. So method code _must_
know which instance is calling it.
Alan Lloyd
.
- Follow-Ups:
- Re: Event handlers...
- From: swansnow
- Re: Event handlers...
- References:
- Event handlers...
- From: swansnow
- Re: Event handlers...
- From: Rob Kennedy
- Event handlers...
- Prev by Date: Re: DBGrid1.OnDrawColumnCell goes into infinite loop
- Next by Date: Re: Test if memory pointer is valid?
- Previous by thread: Re: Event handlers...
- Next by thread: Re: Event handlers...
- Index(es):
Relevant Pages
|