DelphiFAQ Home Search:
General :: Programming :: Delphi
General Delphi related information.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

Hide properties without using TCustomXXX classes

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.
 

Generated 20:01:41 on May 26, 2018