On 23/12/2006, at 9:47 AM, Tom Benson wrote:
Woudn't you need to cast it as a MyEditField (rather than a
vanilla Editfield) in order to trigger a custom method..
ie.
if app.LayoutPraticiens.Control(i) isa MyEditField then
MyEditField(app.LayoutPraticiens.Control(i)).raz
If the method is, as seems the case here, a method of MyEditField
then yes and there will be a compiler error to tell you that raz is
not a method of EditField.
The other two possibilities:
1) the method is in EditField and then a polymorphic override
exists with a copy in MyEditField. In that case, despatching via
the parent class will be legal and the normal virtual method
resolution will take place. (In C++ terms, you are casting a
pointer to point to the parent class.)
Are you sure Andy? I would have thought that
a) if you'd overridden an Editfield method, and
b) then cast a control in a loop like this as an Editfield and not as
a MyEditfield
then the result would be a call to the Editfield function, and not
the MyEditfield function...
In fact I rely on this heavily in a number of my projects (being able
to call a superclasses method that I have overridden by casting the
object as it's superclass)
I've had no formal OOP education beyond a basic dalliance with Java
(although I've been using RB for a long time), so please correct me
if this assumption about function overriding is not right...
I've been wrong often enough, and assumption is the mother of all
f*#k ups afterall.
- Tom
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>