[SOLVED] Hide property lazarus / 21-General ---------------------------------------------------------------------- pcurtis · 2021-05-10 16:30 With the following code I can make a new Timer component. How can I hide the Enabled property in the object inspector? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit MyTimer; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls; type  TMyTimer = class(TTimer)  private    fOneShot : boolean;    function GetOneShot : boolean;    procedure SetOneShot(aValue : boolean);  protected   public    constructor Create(AOwner : TComponent); override;    procedure Reset;    procedure Start;    procedure Stop;  published    procedure DoOnTimer; override;    property OneShot : boolean read GetOneShot write SetOneShot;  end; procedure Register; implementation {$R MyTimer.res}  constructor TMyTimer.Create(AOwner : TComponent);begin  Enabled := False;  fOneShot := False;  inherited Create(AOwner);end; procedure TMyTimer.DoOnTimer;begin  inherited;  if fOneShot then Self.Enabled := False;end; procedure TMyTimer.Start;begin  Self.Enabled := True;end; procedure TMyTimer.Reset;begin  Self.Enabled := False;  Self.Enabled := True;end; procedure TMyTimer.Stop;begin  Self.Enabled := False;end; function TMyTimer.GetOneShot : boolean;begin  Result := fOneShot;end; procedure TMyTimer.SetOneShot(aValue : boolean);begin  If GetOneShot <> aValue then    begin      fOneShot := aValue;    end;end; procedure Register;begin  RegisterComponents('Misc',[TMyTimer]);end; end. ---------------------------------------------------------------------- Mr.Madguy · 2021-05-10 16:38 Try this: 1) Declare the same property in another section. For example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TMyTimer = class(TTimer)public  property Enabled;end; 2) Inherit from TCustomTimer (if it exists) ---------------------------------------------------------------------- Remy Lebeau · 2021-05-10 17:03 Quote from: pcurtis on May 10, 2021, 06:30:03 pmHow can I hide the Enabled property in the object inspector? See Hide Properties (UnlistPublishedProperty) ---------------------------------------------------------------------- pcurtis · 2021-05-10 17:11 @Mr.Madguy doesn't work @Remy Lebeau Means nothing to me ---------------------------------------------------------------------- Mr.Madguy · 2021-05-10 18:26 Quote from: pcurtis on May 10, 2021, 07:11:51 pm@Mr.Madguy doesn't work At least 2nd one should work (1st one is easier, but isn't guaranteed to work), because it's real reason, why we need TCustom controls. See how TTimer is declared and do the same: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses CustomTimer; type  TMyTimer = class (TCustomTimer)  published    //property Enabled;    property Interval;    property OnTimer;    property OnStartTimer;    property OnStopTimer;  end; ---------------------------------------------------------------------- pcurtis · 2021-05-10 18:50 @Mr.Madguy Job done. It works. Thanks. ---------------------------------------------------------------------- Remy Lebeau · 2021-05-11 00:56 Quote from: pcurtis on May 10, 2021, 07:11:51 pm@Remy Lebeau Means nothing to me  It means you can register the THiddenPropertyEditor class for the property you want to hide at design-time (it will still be available at runtime), eg: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit MyTimer; {$mode objfpc}{$H+} interface uses  ...     type  TMyTimer = class(TTimer)    ...  end;     procedure Register;     implementation     {$R MyTimer.res} uses  PropEdits;     ...     procedure Register;begin  RegisterComponents('Misc', [TMyTimer]);  RegisterPropertyEditor(TypeInfo(Boolean), TMyTimer, 'Enabled', THiddenPropertyEditor);end; end. But, using the approach of deriving TMyTimer from TCustomTimer and NOT promoting the Enabled property to published is a better way to go.  It also hides the Enabled property at runtime, too.  I wasn't aware that FreePascal had TCustomTimer (Delphi doesn't). ---------------------------------------------------------------------- PascalDragon · 2021-05-11 06:31 Quote from: Remy Lebeau on May 11, 2021, 02:56:24 amBut, using the approach of deriving TMyTimer from TCustomTimer and NOT promoting the Enabled property to published is a better way to go.  It also hides the Enabled property at runtime, too.  I wasn't aware that FreePascal had TCustomTimer (Delphi doesn't). It's more correct to say that Lazarus or the LCL has TCustomTimer, not Free Pascal. ---------------------------------------------------------------------- Mr.Madguy · 2021-05-11 08:28 Quote from: Remy Lebeau on May 11, 2021, 02:56:24 amBut, using the approach of deriving TMyTimer from TCustomTimer and NOT promoting the Enabled property to published is a better way to go.  It also hides the Enabled property at runtime, too.  I wasn't aware that FreePascal had TCustomTimer (Delphi doesn't). Can't check it now - will do it later, but I think, that any control should have TCustom analog both in Delphi and Lazarus.