SJohnson
asked on
Hiding Component Property
Hi there,
I've made my own component with an ancestor of TSpeedButton. I need to remove the TFont property (so it doesn't appear in the IDE etc). Can anyone tell me how to do it? I'm at a total loss.
Thanks a million (or 125 points).
Stu.
I've made my own component with an ancestor of TSpeedButton. I need to remove the TFont property (so it doesn't appear in the IDE etc). Can anyone tell me how to do it? I'm at a total loss.
Thanks a million (or 125 points).
Stu.
redeclare it in the Private section?
Hello
DragonSlayer, I don't think it's possible with Delphi, you can't unpublish a published property
but you can hide it from Ojbect Inspector by Register the property editor with nil
try this
RegisterPropertyEditor(Typ eInfo(TFon t), TMySpeedButton, 'Font', nil);
Regards,
mohammed
DragonSlayer, I don't think it's possible with Delphi, you can't unpublish a published property
but you can hide it from Ojbect Inspector by Register the property editor with nil
try this
RegisterPropertyEditor(Typ
Regards,
mohammed
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That's right Geo,
But in that way, you will not be able to set Font property at all
But in that way, you will not be able to set Font property at all
Of course, Mohammed. I thought it was the question: to remove a published property from a component.
Geo's method is the right one
> But in that way, you will not be able to set Font property at all
That's not completly right as he can already access the inherited font property by code
for example:
procedure TForm1.MySpeedButton1Click (Sender: TObject);
begin
with Sender as TMySpeedButton do
inherited font.Size := 10;
end;
F68 ;-)
> But in that way, you will not be able to set Font property at all
That's not completly right as he can already access the inherited font property by code
for example:
procedure TForm1.MySpeedButton1Click
begin
with Sender as TMySpeedButton do
inherited font.Size := 10;
end;
F68 ;-)
F68
Cool :-)
Cool :-)
Inherited properties can be accessed from inside the component's methods or from outside as F68 showed. There is nothing that can be done for preventing that (as far as I know). But TMySpeedButton.Font won't be visible in ObjInspector and won't be settable. Declaring TMySpeedButton.Font that way doesn't override the inherited Font but only hides it.
Regards, Geo
Regards, Geo
Hi Stu,
It's not possible hide a published property. This is the Delphi's approach to the object oriented programming.
- protected property can be turn into public
- public property can be turn into published
but you can't make the published to public and public to protected. It's the same for the situation you faced with now. Font property inherited from the TControl ancestor. It's the property which is protected in TControl and published in TSpeedButton so it's not possible to hide it
+ TControl
|
+ TGraphicControl
|
- TSpeedButton
Cheers,
Oktay Sancak
It's not possible hide a published property. This is the Delphi's approach to the object oriented programming.
- protected property can be turn into public
- public property can be turn into published
but you can't make the published to public and public to protected. It's the same for the situation you faced with now. Font property inherited from the TControl ancestor. It's the property which is protected in TControl and published in TSpeedButton so it's not possible to hide it
+ TControl
|
+ TGraphicControl
|
- TSpeedButton
Cheers,
Oktay Sancak
ceoworks, that's right, but the question here is about hiding a property from object inspector (IDE) not from component.
So the way suggested by geobul is the simplest and quickest to do this
So the way suggested by geobul is the simplest and quickest to do this
oppssssssss, sorry ignore my last commet, it's post on the wrong place :-(
Yeah Ferruccio, I think so... Just i wanted to provide some explanation for to make it clear the Delphi's approach to the properties and their visibleness.
Have a nice day :)
Oktay,
Have a nice day :)
Oktay,
ASKER
Thanks very much, Geo. And thanks to everyone else for the comments too. I learn something new all the time here!!
Legendary!
Stu
Legendary!
Stu