Solved

Hiding Component Property

Posted on 2004-10-12
14
447 Views
Last Modified: 2013-11-23
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.
0
Comment
Question by:SJohnson
  • 5
  • 3
  • 2
  • +3
14 Comments
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12295319
redeclare it in the Private section?
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 12295620
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(TypeInfo(TFont), TMySpeedButton, 'Font', nil);

Regards,
mohammed
0
 
LVL 17

Accepted Solution

by:
geobul earned 125 total points
ID: 12295931
Hi,

You could hide a property from Object inspector by making it ReadOnly:

private
  FHiddenProperty : Boolean;
published
   property Font : Boolean read FHiddenProperty ;
end;

Regards, Geo
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 12296004
That's right Geo,

  But in that way, you will not be able to set Font property at all
0
 
LVL 17

Expert Comment

by:geobul
ID: 12296649
Of course, Mohammed. I thought it was the question: to remove a published property from a component.
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12296679
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 ;-)
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 12296691
F68
Cool :-)
0
 
LVL 17

Expert Comment

by:geobul
ID: 12296805
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
0
 
LVL 4

Expert Comment

by:ceoworks
ID: 12296830
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
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12296876
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
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 12296907
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 12296918
oppssssssss, sorry ignore my last commet, it's post on the wrong place :-(
0
 
LVL 4

Expert Comment

by:ceoworks
ID: 12297166
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,
0
 
LVL 1

Author Comment

by:SJohnson
ID: 12304497
Thanks very much, Geo.  And thanks to everyone else for the comments too.  I learn something new all the time here!!

Legendary!

Stu
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to fill array with TArray.Create? 14 90
Making delphi communicate with a c# service 16 103
select query - oracle 16 100
Dynamically Created Query 3 55
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question