Solved

Hiding ancestor methods

Posted on 1998-05-26
4
301 Views
Last Modified: 2010-04-06
Is there any way to hide/disable the methods and properties when creating a component based on another component ?
0
Comment
Question by:JustinCase
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Expert Comment

by:ssite
ID: 1347984
Yeap. If the methods are virtual (can be overriden).

For methods :

Override the method, then just don't call inherited.

For properties

publish the same property (exact name), use both a get and a set function and just don't do anything. (for the get - return something)

Why do you want to do this ?
0
 

Author Comment

by:JustinCase
ID: 1347985
This does not remove the method from the object inspector (I tried it with the OnClick). I should have mentioned that.

I'm creating a specific protocol component from a Serial Com component and do not want public access to a number of methods.

I hope I can avoid cleaning old source.


0
 
LVL 1

Accepted Solution

by:
ssite earned 50 total points
ID: 1347986
OnClick for your knowledge is an EVENT, not a method. To hide onclick (tough) I think you should just inherit from a level which doesn't publish it. Most TCUSTOMXXXX components don't publish anything.

Try it.
0
 
LVL 4

Expert Comment

by:d003303
ID: 1347987
Yo,
there are four privacy levels of an object. Private, protected, public and published. All methods, properties and events can be moved one or more levels into the "visible direction", but not back. Example: You inherit a component from TPanel and it would be possible to hide the owner property. This component would never work because other components on a form need to read this property. To ensure that all objects behave at least like their ancestors (this is polymorphism, e.g. the Sender variable in a TNotifyEvent can carry any TObject descendant, but mostly they are components), this is not allowed.

If you only want to hide published properties or events in object inspector at design time, re-publish them as e.g.
   property Caption : string read FCaption;
and add a private variable
   FCaption : string;
to fool object inspector. The caption property is still read AND writeable (because of polymorphism), but object inspector thinks it is read-only and hides the property at design time.

Have fun,
Slash/d003303
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

734 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