DelphiFAQ Home Search:

Hide properties without using TCustomXXX classes

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

Sometimes you will want to hide some properties from access by the object inspector. Unfortunately, VCL does not always offer you TCustomXXX classes where all properties are protected.
The following trick shows, how to do it..
This piece of code hides the properties VertScrollbar and HorzScrollbar in the object inspector and shows how to access the hidden properties in your source code (see method Switch).

unit HideProp;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs;

type
  THideProp = class(TScrollBox)
  private
    Foo: Boolean;
  protected
  public
  published
    { the properties which are to hide are redefined as
	  read-only dummy properties.
      That way they will not appear in object inspector. }
    property VertScrollBar: Boolean read Foo;
    property HorzScrollBar: Boolean read Foo;
    procedure Switch;   { activate/deactivate scrollbars }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Sample', [THideProp]);
end;

{ Toggle for Scrollbars. Just a sample to show,
  how you still can access the original properties.. }
procedure THideProp.Switch;
begin
  inherited VertScrollBar.Visible := Not inherited VertScrollBar.Visible;
  inherited HorzScrollBar.Visible := Not inherited HorzScrollBar.Visible;
end;

end.

Comments:

2008-05-15, 14:47:20
anonymous from United States  
What do you begin the code with? is it like:

<css>
*text*
</css>

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Washington, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.