Link to home
Start Free TrialLog in
Avatar of scrapdog
scrapdogFlag for United States of America

asked on

Overriding/hiding inherited published properties

I am making a component that is a descendent of TDrawGrid.

Lets say that I want these properties (among others) to be published:  Width, Height, ColCount, RowCount.

When the user changes one of these, I want the methods found in DrawGrid to take care of it.  However, before this is done, I need my component to take care of some other things, such as memory allocation.

For example, say that the user increases RowCount by 1.  I need to allocate additional memory and do some other things (for the purpose of my component), and then let TDrawGrid do whatever is needed to change the rows.

How would I hide the inherited properties, and include new properties of the same name that call the inherited properties?  I think I should use the "inherited" keyword, but I am not exactly sure.

Another, similar question:

How would I hide (i.e. make private to my component) any inherited published properties, yet still make them available to my component?

For example, lets say I wanted to make Height and Width (in DrawGrid) totally unavailable to the user and other components, but I want to retain them for private use by my component.  How would I do that?

If it matters, I am using Delphi 2.
ASKER CERTIFIED SOLUTION
Avatar of Madshi
Madshi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Madshi
Madshi

Of course you should change (TEdit) to (TDrawGrid)...  :-)
Avatar of scrapdog

ASKER

OK.  Thanks.  Just a couple of things I need clarified.

1.  If I DID want to make the Width property (the new property for my component, as shown in your code) visible to others, I just simply move it from private to public or published, right?

2.  Let's say I wanted to totally hide FixedRows and not do anything with it.  All I want to do is keep the user from changing it.  Do I simply exclude it from my property definitions, or is there more to it?
Adjusted points to 65
(1) That's right...  :-)
(2) Hmmm. If you derive your component from TDrawGrid then your component will have all properties published, that TDrawGrid published, too. That means you have to DO something in order to hide such a property.
You could try just this:
  private
    FixedRows;
  public
Perhaps that's all. I'm not sure about that. If it doesn't work, then use the same stuff as I showed you with the Width property, but just leave your GetFixedRows/SetFixedRows functions empty.

Regards, Madshi.
Thanks.