Solved

Remove a property

Posted on 2001-07-24
24
232 Views
Last Modified: 2013-11-23
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 .
0
Comment
Question by:ginsonic
  • 7
  • 7
  • 4
  • +3
24 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6312066
as far as i know are published propertys never removeable,

look for a TCustom...-Class from where you inherit your new class
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6312158
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
 
LVL 21

Expert Comment

by:gemarti
ID: 6312198
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
 
LVL 17

Expert Comment

by:geobul
ID: 6312419
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
 

Expert Comment

by:meirchen
ID: 6312503
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
 
LVL 9

Author Comment

by:ginsonic
ID: 6312574
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
 
LVL 17

Expert Comment

by:geobul
ID: 6312850
> 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
 
LVL 9

Author Comment

by:ginsonic
ID: 6314197
I wish to remove this property from my object inspector .
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6314550
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
 
LVL 9

Author Comment

by:ginsonic
ID: 6315779
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6316102
where can i find it?
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6316582
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 20

Accepted Solution

by:
Madshi earned 50 total points
ID: 6316619
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6316674
because it is a readonly property now ...
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6316822
Right...  :-)  (Bin gerade das erste mal mit TDSL online - whooooooooooo, das brennt...)
0
 
LVL 17

Expert Comment

by:geobul
ID: 6317030
Yes, that's what I had in mind ;-)
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6320736
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
 
LVL 17

Expert Comment

by:geobul
ID: 6320912
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
 
LVL 20

Expert Comment

by:Madshi
ID: 6320939
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
 
LVL 17

Expert Comment

by:geobul
ID: 6320966
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
 
LVL 9

Author Comment

by:ginsonic
ID: 6321370
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
 
LVL 17

Expert Comment

by:geobul
ID: 6321494
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
 
LVL 9

Author Comment

by:ginsonic
ID: 6321673
I have founded , too . But I keep my promise and I will give you 200 points .
Look for 'Points for geobul'
0
 
LVL 17

Expert Comment

by:geobul
ID: 6321955
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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now