 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Elizabeth Guest
|
Posted: Tue May 18, 2004 9:34 am Post subject: Hiding properties and events of an ancestor |
|
|
Hi All,
When a component is derived from some other component , the child component
inherits all the properties and events of the parent component which we call
ancestor.So all the properties and events which are published in the
ancestor are also published in the child component and we can view them in
the object inspector.
Suppose i do not want to publish these or i want to hide these properties
and events , then is there a way out ?.
thanks in advance to all,
Elizabeth
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue May 18, 2004 5:01 pm Post subject: Re: Hiding properties and events of an ancestor |
|
|
"Elizabeth" <mnkd (AT) ffjn (DOT) com> wrote
| Quote: | Suppose i do not want to publish these or i want to hide
these properties and events , then is there a way out ?.
|
Derive from a lower base class that does not already publish them. Then you
can publish only the ones you want. That is why the VCL is littered with
TCustom... classes, for exactly that purpose.
It has been suggested that you can register a NULL property editor for any
property that you want to "hide". I have not tried that myself, though.
Gambit
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue May 18, 2004 9:30 pm Post subject: Re: Hiding properties and events of an ancestor |
|
|
"Roddy Pratt" <roddy at rascular dot com> wrote
| Quote: | There's a Delphi technique of redefining the property to hide
with a read-only virtual abstract 'getter' function, (== C++
pure virtual) but that's a nono in C++, as you can't instantiate
abstract classes.
|
You can't instantiate abstract classes in Delphi, either.
Gambit
|
|
| Back to top |
|
 |
Roddy Pratt Guest
|
Posted: Tue May 18, 2004 9:33 pm Post subject: Re: Hiding properties and events of an ancestor |
|
|
"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote
| Quote: | It has been suggested that you can register a NULL property editor for any
property that you want to "hide". I have not tried that myself, though.
|
There's a Delphi technique of redefining the property to hide with a
read-only virtual abstract 'getter' function, (== C++ pure virtual) but
that's a nono in C++, as you can't instantiate abstract classes. See
http://www.undu.com/Articles/990331a.html
Redefining the property as 'read-only' (no 'write' in the __property
statement will make the property disappear from the inspector, but it's
still accessible from the language. Which may be OK for you?
- Roddy
|
|
| Back to top |
|
 |
Roddy Pratt Guest
|
Posted: Tue May 18, 2004 10:01 pm Post subject: Re: Hiding properties and events of an ancestor |
|
|
"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote
| Quote: |
You can't instantiate abstract classes in Delphi, either.
So does the Delphi article I linked to work, then? Surely one abstract |
function makes the class abstract in Delphi, like a pure virtual function
does in C++? I got the impression Delphi would only throw an error when
you actually call the abstract function...
Roddy
- Confused of Shropshire...
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue May 18, 2004 10:28 pm Post subject: Re: Hiding properties and events of an ancestor |
|
|
"Roddy Pratt" <roddy at rascular dot com> wrote
| Quote: | So does the Delphi article I linked to work, then?
|
I don't know, I don't have Delphi available to try with.
| Quote: | Surely one abstract function makes the class abstract in
Delphi, like a pure virtual function does in C++?
|
Yes. In Delphi, 'abstract' is the same as 'virtual ... = 0' in C++.
| Quote: | I got the impression Delphi would only throw an
error when you actually call the abstract function...
|
I thought Delphi wouldn't allow it, but I just tried compiling some test
code and it generated only a warning instead of an error.
Gambit
|
|
| Back to top |
|
 |
Roddy Pratt Guest
|
Posted: Tue May 18, 2004 11:28 pm Post subject: Re: Hiding properties and events of an ancestor |
|
|
Re: Delphi Abstract classes
"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote in message
| Quote: | I thought Delphi wouldn't allow it, but I just tried compiling some test
code and it generated only a warning instead of an error.
|
Strange but true. Check out object pascal compiler error #175 in online
help.
"type
Base = class
procedure Abstraction; virtual; abstract;
end;
- snip -
An abstract procedure does not exist, so it becomes dangerous to create
instances of a class which contains abstract procedures -snip- Any
invocation of 'Abstraction' through the instance of 'b' created here would
cause a runtime error."
- Roddy
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|