Solved

Remove a property

Posted on 2001-07-24
24
236 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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
 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
add combobox item based on numbers 9 141
Delphi Form ownership 4 88
DBGrid or StringGrid ? 6 88
Delphi: barcode reading on android platform 1 28
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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