Remove a property

I wish to create a new popup menu vcl but in same time I wish to remove the MenuAnimation property .
How can I do that ?

Nick
P.S. For working samples I will increase to 50 points .
LVL 9
ginsonicAsked:
Who is Participating?
 
MadshiConnect With a Mentor Commented:
This one hides the MenuAnimation property from the object inspector in my D6:

type
  TPopupMenuHiddenProp = class(TPopupMenu)
  private
    FMenuAnimation : boolean;
  published
    property MenuAnimation : boolean read FMenuAnimation;
  end;

procedure Register;
begin
  RegisterComponents('ginsonic', [TPopupMenuHiddenProp]);
end;

Regards, Madshi.
0
 
kretzschmarCommented:
as far as i know are published propertys never removeable,

look for a TCustom...-Class from where you inherit your new class
0
 
MadshiCommented:
Maybe you can redefine the MenuAnimation property in the privated area of your class, but you'll (1) get a compiler warning because of that and (2) I don't know whether it really has the desired effect. The other solution would be (as meikl already pointed out) creating a component from scratch, then you have full control over the published properties...

Regards, Madhsi.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
gemartiCommented:
You create a new component class and override the constructor:

type
  TPopupMenu1 = class(TPopupMenu)
  private
    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override
  published
    { Published declarations }
  end;

You then create the properties you want for the new component:

type
  TPopupMenu1 = class(TPopupMenu)
  private
    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override
  published
    { Published declarations }
    Property WordWrap default False;
    .
    .
    .
    Property Something default 0;
   property
  end;

Just leave off the property you don't want;
0
 
geobulCommented:
Hi,

You can make it readonly at least:

TMyPopupMenu = class(TPopupMenu)
  protected
    function GetMenuAnimation: TMenuAnimation;
  public
    constructor Create(AOwner: TComponent); override;
  published
    property MenuAnimation: TMenuAnimation read GetMenuAnimation;
  end;

constructor TMyPopupMenu.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
end;

function TMyPopupMenu.GetMenuAnimation: TMenuAnimation;
begin
  result := inherited MenuAnimation;
end;

Regards, Geo
0
 
meirchenCommented:
I think it is possible to just place the property in the public part of the component, in that way it won't be shown in the property page.

eg:

TNewPopupMenu = class(TPopupMenu)
 public
   property MenuAnimation;
 published
 end;


 
0
 
ginsonicAuthor Commented:
geobul , don't work .
kretzschmar the TPopupMenu don't have a custom class .

I wish to say that  TAnimatedMenu 2000 have a PopupMenu vcl derived from standard class but without standard properties .

If you find the trick used by AnimatedMenu's author ... I will increase to 100 points .
0
 
geobulCommented:
> geobul , don't work .
What does it mean? You are still seeing the property, but can't change its default value of [] and can't write MyMenu.MenuAnimation := [maLeftToRight]; for example.
0
 
ginsonicAuthor Commented:
I wish to remove this property from my object inspector .
0
 
kretzschmarCommented:
thats the declaration of tpopup in the vcl

  TPopupMenu = class(TMenu)
  private
    FPopupPoint: TPoint;
    FAlignment: TPopupAlignment;
    FAutoPopup: Boolean;
    FPopupComponent: TComponent;
    FTrackButton: TTrackButton;
    FMenuAnimation: TMenuAnimation;
    FOnPopup: TNotifyEvent;
    function GetHelpContext: THelpContext;
    procedure SetHelpContext(Value: THelpContext);
    procedure SetBiDiModeFromPopupControl;
  protected
    function UseRightToLeftAlignment: Boolean;
    procedure DoPopup(Sender: TObject); virtual;
    property PopupPoint: TPoint read FPopupPoint;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure Popup(X, Y: Integer); virtual;
    property PopupComponent: TComponent read FPopupComponent write FPopupComponent;
  published
    property Alignment: TPopupAlignment read FAlignment write FAlignment default paLeft;
    property AutoHotkeys;
    property AutoLineReduction;
    property AutoPopup: Boolean read FAutoPopup write FAutoPopup default True;
    property BiDiMode;
    property HelpContext: THelpContext read GetHelpContext write SetHelpContext default 0;
    property Images;
    property MenuAnimation: TMenuAnimation read FMenuAnimation write FMenuAnimation default [];
    property OwnerDraw;
    property ParentBiDiMode;
    property TrackButton: TTrackButton read FTrackButton write FTrackButton default tbRightButton;
    property OnChange;
    property OnPopup: TNotifyEvent read FOnPopup write FOnPopup;
  end;

if you will get rid property MenuAnimation you have also to derive your TPopupmenu from TMenu

meikl ;-)
0
 
ginsonicAuthor Commented:
I don't wish to rewrite the PopupMenu vcl . If you have time to take a look at AnimatedMenu2000 source you will can see that the author create a custom class derived from ... TPopupMenu .
0
 
kretzschmarCommented:
where can i find it?
0
 
kretzschmarCommented:
because it is a readonly property now ...
0
 
MadshiCommented:
Right...  :-)  (Bin gerade das erste mal mit TDSL online - whooooooooooo, das brennt...)
0
 
geobulCommented:
Yes, that's what I had in mind ;-)
0
 
ginsonicAuthor Commented:
I increase to 50 points ( for a working sample ).
Madshi , your ideea work for me . If today I will not receive a better ideea you have my 'vote' .

But I'm still  interested to know the AnimatedMenu ideea for my question .
I offer now 200 points and an A grade for this .
0
 
geobulCommented:
Hi all,
Could someone be so kind to explain to me why Madshi's solution is acceptable but mine is not?

Redeclaring the type of a property in the descendant class hides the inherited property instead of overriding it. It doesn't matter that both types are same (TMenuAnimation in my case). Is it right?

Regards, Geo
0
 
MadshiCommented:
Hi Geo,

I didn't test your solution. ginsonic said it didn't work, so I just played a bit and found what I was posting here. Maybe yours works, too. In that case the points should be yours, of course.

Regards, Madshi.
0
 
geobulCommented:
Hi Madshi,
I'm not interested in the this question points, because in my opinion there is no way to entirely remove an already declared property. I can always typecast TPopupMenu(MyMenu).MenuAnimation := [maNone]; and it will be performed(no compilation or run-time errors at least). I'm interested in possible solutions, that's why I'm asking - to improve my OOP knowledge.

Regards, Geo
0
 
ginsonicAuthor Commented:
geobul ,
Your code don't HIDE the MenuAnimation property, sorry .
I wish to create my own animation effects .

But maybe you can help me with the secod problem .
I offer 200 new points for this ( of course , I will put a new question on Ex-Ex ) .
0
 
geobulCommented:
Hi,
It's done there exactly as Madshi said. The author has used integer instead of boolean, but it's not important.

TCustomPopupMenu2000 = class(T_AM2000_PopupMenu)
private
...
FHideProperty : Integer;
published
...
property MenuAnimation: Integer read FHideProperty;
end;

Obviously it's mandatory to change the property type when redeclaring it. It's not enough to repeat the inherited type declaration.

Regards, Geo
0
 
ginsonicAuthor Commented:
I have founded , too . But I keep my promise and I will give you 200 points .
Look for 'Points for geobul'
0
 
geobulCommented:
Hi ginsonic,
Thank you very much. I don't think that I've helped you much. On the contrary: I misled you. I feel guilty. BTW Madshi's solution to use boolean vs integer is the better one because you will save 3 bytes per instance.
Regards, Geo
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.