Forum > General
[SOLVED] Hide property
pcurtis:
With the following code I can make a new Timer component.
How can I hide the Enabled property in the object inspector?
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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:
Try this:
1) Declare the same property in another section. For example:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TMyTimer = class(TTimer)public property Enabled;end; 2) Inherit from TCustomTimer (if it exists)
Remy Lebeau:
--- Quote from: pcurtis on May 10, 2021, 06:30:03 pm ---How can I hide the Enabled property in the object inspector?
--- End quote ---
See Hide Properties (UnlistPublishedProperty)
pcurtis:
@Mr.Madguy doesn't work
@Remy Lebeau Means nothing to me :(
Mr.Madguy:
--- Quote from: pcurtis on May 10, 2021, 07:11:51 pm ---@Mr.Madguy doesn't work
--- End quote ---
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<xxx> controls. See how TTimer is declared and do the same:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses CustomTimer; type TMyTimer = class (TCustomTimer) published //property Enabled; property Interval; property OnTimer; property OnStartTimer; property OnStopTimer; end;
Navigation
[0] Message Index
[#] Next page