Hide a property from object inspector in delphi - delphi

I want to make a new component.
How can I hide the Caption property in the object inspector?
I use TPanel as ancestor class.

Use TCustomPanel as the base class and publish the properties you need.

by using UnlistPublishedProperty. At this link http://delphihaven.wordpress.com/2009/05/17/tip-removing-a-property-at-design-time/ you can find a fully explained example.
LE: as good practice you should create another class, descendant of TCustomPanel and publish only the properties you need/want.

Related

How to use two properties for a single property editor?

Refer to this prior question/answer combo of mine. It's describing how to create a property editor for the IDE.
I've created another property editor for a completely different purpose. In this case, it's a glyph character selector of type String (because it could contain more than one glyph character). Unlike my other one in mentioned question/answer, this one is very specific to a particular property on a particular TCollectionItem class of mine.
All is good, and I can invoke this property editor for this particular property. However, I have a dilemma. The property editor, by nature, is directly related to a font. The user may choose a character (glyph) from a particular font. My property editor has the facility to change the font, and browse the glyphs contained within that font.
This component of mine also has the facility to specify the font, in a separate TFont property. The problem arises when it comes to the combination of both my Glyph property and Font property being used in the very same property editor. When I invoke this editor for the Glyph property, it also needs to know the Font which it needs to use. On the contrary, when user chooses a font and glyph character in this editor, it also needs to update both the Glyph and Font properties.
Long story short, PropertyB depends on PropertyA. If PropertyA changes, then PropertyB will have an entirely different set of possible values. So, whatever editor I install in the IDE needs to allow the user to change both PropertyA and PropertyB at the same time.
How can I make a property editor have access to more than one property?
TPropertyEditor has a public GetComponent() method that you can use to access the object(s) whose property is currently being edited (multiple objects with the same property can be edited at the same time, if the property editor allows it). Then you will have access to all of the other properties in the same object(s).
That being said, if your editor displays a pop-up dialog for editing, it should be implemented as a component editor instead of (or in addition to) a property editor. A property editor should edit only one property at a time, though it may have read-only dependancies on other properties. For instance, a Glyph property editor that also edits the Font property, and vice versa, is not a good design. But a component editor that edits both is perfectly acceptable.
Solution 1
Instead of a property editor, implement a component editor. Such a component editor will have access to the entire component, not just a single property.
Solution 2
Wrap both of your properties inside of a dedicated TPersistent class, and then create a TClassProperty property editor for this class instead. The individual properties will not actually invoke a property editor. Instead, their parent TPersistent will invoke a combined property editor which has access to all the properties within this class. A good existing example is the TFont editor.

Removing properties from Object Inspector

I bought the TMS Component pack and want to hide some component properties from displaying in the object inspector.
I am using UnlistPublishedProperty to hide them.
It works most of the time. But for some reason e.g. Anchors or StyleSettings are still displayed.
I am calling it like this:
UnlistPublishedProperty(TAdvEdit, 'StyleElements');
The weird thing is that it works on 90% of properties and i can't figure out why it will not hide the other properties from the object inspector.
I could edit the source and comment out the line where it gets published from TCustomEdit but i am wondering why the method with UnlistPublishedProperty isn't working.
Thanks!
The properties you are trying to remove are inherited from a higher ancestor class. If you wish to use UnlistPublishedProperty to remove these particular properties, you'll have to remove them from the ancestor. However, that would apply to all controls, not just the one you're working on.
In addition to Jerry's answer; there is a solution for deleting properties from sub-components. The third part of my answer here demonstrates how to filter out properties of a sub-component of a custom component by registering a component PropertyEditor and overriding GetProperties to filter specific property names.

Expose sub components to Delphi designer

I have created a component inheriting TFrame and added an ActionList and ToolBar to the frame as I want to make a base form available to other projects and developers. The question is: how can I expose the ActionList property at design time? The ActionList is showing in the object inspector and I can see it's events and properties, but the actions inside the ActionList are not available at design time.
More details:
I have created a class inheriting from TFrame and added an TActionList in the Delphi IDE designer. Then I added it to a package and installed it as a component. Now I can drop that component on a form and it adds the whole frame I designed to the form. I see the ActioList in the object inspector, but the problem is I cannot see the actions inside the ActionList. I need to add actions to ActionList on the forms which are using the component.

How to put my published properties into the specified category of Object Inspector?

I have my own visual component. It has many published properties and events. I want them to be shown in the specified standard categories of Object Inspector at design-time (Visual, Layout, Drag Drop / Docking, Linkage etc).
Now all my properties are in the Miscellaneous category.
You can use RegisterPropertyInCategory function, defined in the DesignIntf. Example.

Creating custom Hint window

I'm trying to find a way to use my 2nd form as a hint window for a component (for example a TLabel) in my 1st form.
At the moment, I'm exploring the use of THintWindow and HintWindowClass, but it is not possible to directly assign a TForm to HintWindowClass. Some examples I've seen so far use a TBitmap which is then drawn on the THintWindow.Canvas, which is not bad, but I'd still like to use some kind of integrated automatic mechanism.
Another solution that crossed my mind is to manually implement this functionality using OnMouseEnter, OnMouseMove and OnMouseLeave events of the said Tlabel.
If there actually is a way to "assign" a TForm to HintWindowClass, I'd like to ask if anyone can provide a code snippet illustrating this. Thanks.
THintWindow is a descendant of TCustomControl. TForm is not a descendant of either of those classes, so you cannot assign any TForm class to HintWindowClass. Hint windows need to descend from THintWindow. Anything you can put on a form you can also put on a THintWindow. You'll just have to instantiate it manually and assign its Parent property to make it appear.
The closest you can probably get to "visually" designing a hint window is to design a frame. Make your THintWindow descendant create an instance of the frame, and then override ActivateHint (and ActivateHintData, if you need the data) to forward the hint text and desired size to your frame.

Resources