Author: Pablo Reyes
In Delphi 5 the object inspector allow us to view properties and events by
categories. We can instruct Delphi which category the properties and events of our
components belongs to and even to create our own categories.
1. To instruct Delphi which category a property belongs to:
We have to do that in the Register procedure. The function
RegisterPropertyInCategory has four overloaded versions. This is one of them. In
this version we instruct Delphi to assign the property "Version" of our component
"TMyButton" to the "TMiscellaneousCategory" standard category.
2 begin3 RegisterComponents('Samples', [TMyButton]);
4 RegisterPropertyInCategory(TMiscellaneousCategory, TMyButton, 'Version');
Search Delphi help for more information about other overloaded versions of this
2.To create our own category:
We have to create a new class and derive it from TPropertyCategory or one of the
existing categories (for example TMiscellaneousCategory). Then, we need to override
the Name class function. The result value is the name shown by the object
6 interface7 8 TMyCategory = class(TPropertyCategory)
9 public10 classfunction Name: string; override;
12 13 implementation14 15 classfunction TMyCategory.Name: string;
16 begin17 Result := 'My Category';
19 20 //Then we could use our new category. 21 22 procedureregister;
23 begin24 RegisterComponents('Samples', [TMyButton]);
25 RegisterPropertyInCategory(TMyCategory, TMyButton, 'Version');
You can also use RegisterPropertiesInCategory to register more than one property with one category at a time.