Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to hide published properties on a descendant component?

23 views
Skip to first unread message

Howard Moon

unread,
Jul 11, 2000, 3:00:00 AM7/11/00
to
Hi...
I have a TImage descendant whose AutoSize property I want to always be
True. While I can override this behavior, I can't seem to find a way to
prevent someone who is using my component from changing this value in the
Object Inspector. When run, the override will force it to be True, but what
I want is to physically hide the AutoSize property from the Object
Inspector. I can't seem to find a way to do this, however. Anyone know how
I can hide a published property in a descendant component? Thanks...
-Howard


Guido Geurts

unread,
Jul 11, 2000, 3:00:00 AM7/11/00
to
try redeclaring it in the public section in stead of in the published section.

something like
TMyImage = class(TImage)
public
property AutoSize;
publised
end;

if this works, then do not forget to set the property to TRUE in the creator.

gge.vcf

John Elrick

unread,
Jul 11, 2000, 3:00:00 AM7/11/00
to
You really can't demote the visibility of a property, you can however fake
it out.

published
property AutoSize : boolean read FAutoSize;

Read only properties don't appear in the object inspector.


John Elrick


"Howard Moon" <hm...@landstar.com> wrote in message
news:8kf914$7u...@bornews.borland.com...

Howard Moon

unread,
Jul 11, 2000, 3:00:00 AM7/11/00
to
John,
I tried this method first, but the AutoSize property still appears in the
object inspector when I drop my component on the form, apparently because
the ancestor visibility is "published". Changing the value in the Object
Inspector did not affect the behavior of my component, but I didn't want
users of the component thinking they *could* change the value.

Roger Morton

unread,
Jul 11, 2000, 3:00:00 AM7/11/00
to

I believe the other way to do it is attach a nil property editor - in your Register procedure:

RegisterPropertyEditor(TypeInfo(Boolean), TMyImageDescendent, 'AutoSize', nil);


Roger Morton
roger....@dial.pipex.com

Howard Moon

unread,
Jul 11, 2000, 3:00:00 AM7/11/00
to
Guido,
this does not work. It does not compile because there is no read, write
or index specifier. Adding a read specifier that returns a private variable
that is always true works for getting it to compile, and makes my component
behave correctly, but it does *not* hide the published property. From what
I see in the Help and in Deja News, you can't reduce the visibility from
published to anything else, You can only hide the variable with another
one, but you can't hide the published property itself. Is there some way to
hide the property *editor* for this property (like assigning it to nil
somehow)??? (Too bad there's no TCustomImage for this purpose, or the
ability to reduce visibility of a member variable.)

Guido Geurts <g...@adtechno.be> wrote in message
news:396B348C...@adtechno.be...


> try redeclaring it in the public section in stead of in the published
section.
>
> something like
> TMyImage = class(TImage)
> public
> property AutoSize;
> publised
> end;
>
> if this works, then do not forget to set the property to TRUE in the
creator.
>
> Howard Moon wrote:
>

Howard Moon

unread,
Jul 11, 2000, 3:00:00 AM7/11/00
to
Roger,
that did it! Thank you very much...I was getting quite frustrated with
this...now I can proceed with the real work! Thanks again...

-Howard

Michael Beck

unread,
Jul 11, 2000, 3:00:00 AM7/11/00
to
Howard Moon wrote:
>
> John,
> I tried this method first, but the AutoSize property still appears in the
> object inspector when I drop my component on the form, apparently because
> the ancestor visibility is "published". Changing the value in the Object
> Inspector did not affect the behavior of my component, but I didn't want
> users of the component thinking they *could* change the value.

As posted by Jeff Overcash somewhere else:

You can not reduce visibility of a property. To just hide it from the
ObjectInspector register a nil property editor for that property. In all
other
respects it remains published, but won't show on the OI.

Mark Erbaugh

unread,
Jul 12, 2000, 3:00:00 AM7/12/00
to
There really isn't a way to make a property 'less visible'. This makes sense
if you think about it. Any class instance can always be accessed as an
instance of an ancestor class, so even if you could 'hide' the AutoSize
property in your TImageDescendent class, the programmer could still access
that property by treating the instance as a TImage.
If you look through the VCL heirarchy, there are a number of TCustom...
classes and most of the VCL components descent from these (i.e. TEdit
descends from TCustomEdit). In many cases the only change made in the
descendent class is to make some properties published (rather than
protected). If you need to create a component that doesn't have a certain
property visible, you descend your component from the TCustom.. class.
Unfortunately, TImage is descended from TGraphicControl, not TCustomImage.
AutoSize is a protected property of TGraphicControl, so if you descended
from TGraphicControl, you could keep AutoSize from being visible.
Unfortunately, TImage implements some additional methods which you would
have to copy into your descendent.

Another option would be to instead of creating your component as a
descendent of TImage, make it a descendent of TComponent and have a TImage
as a data member of the component. You can then write access methods for
just the properties you want.

Mark

Howard Moon <hm...@landstar.com> wrote in message
news:8kf914$7u...@bornews.borland.com...

Rudy Velthuis

unread,
Jul 12, 2000, 3:00:00 AM7/12/00
to
Howard Moon wrote...

>Hi...
> I have a TImage descendant whose AutoSize property I want to always be
>True. While I can override this behavior, I can't seem to find a way to
>prevent someone who is using my component from changing this value in the
>Object Inspector.

You could register a nil property editor for the property. Then it will
still be streamed in and out, and remain published, but not appear in the
object inspector.
--
Rudy Velthuis

0 new messages