How to hide inherited published properties in runtime designer?

I use a property inspector ( for example, the good JvInspector in the JVCL library ), which allows me to view and edit the published properties of my TMyClass class. TMyClass omitted from TFrame and has several published properties, which are the only ones that I need to see and edit. Of course, TFrame has many VCL properties, all published, which I also see.

How can I suppress an RTTI parent property and leave my published properties? I use XE3, so the world is my oyster ... maybe.

+6
source share
3 answers

Derive your class from TCustomFrame , and from your class publish only those properties that you need. Although you cannot hide properties already published, many of them are protected and will be hidden when using the TCustomFrame class as the ancestor for your own class.

The way almost every control in a VCL consists of a class hierarchy. For example, TLabel is a TCustomLabel descendant whose only role in the class chain is to publish properties that you can see in the object inspector.

+8
source

FWIW, I found an RTTI solution for this - i.e. allow only properties NOT belonging to the predecessor class or classes, in other words, the properties that you added were published by yourself in the current class. The JvInspector has a BeforeItemCreate event containing the name of the property that appears in the inspector. This solution checks the name of the property in order to be a member of the ancestor class, and only if it is not, does it display it in the inspector. The benefit is that there are no changes to the inspector code.

 uses TypInfo; procedure TForm1.JvInspectorBeforeItemCreate(Sender: TObject; Data: TJvCustomInspectorData; var ItemClass: TJvInspectorItemClass); begin if IsPublishedProp(TFrame, Data.Name) then ItemClass := nil; end; 
+4
source

Create the TMyClass component at run time.


But in order to maintain the ability to edit properties during development, do not go down with TMyClass with TFrame . Instead, go down to:

  • TCustomPanel , if you want to get the border,
  • TCustomControl , if you yourself can make a border,
  • TWinControl , if you can do without a border.

Of course, your TMyClass component TMyClass no longer appear in the Insert Frame dialog box, but it will be just a component like any other.

+3
source

All Articles