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.
Answer:
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.
1 procedureregister;
2 begin3 RegisterComponents('Samples', [TMyButton]);
4 RegisterPropertyInCategory(TMiscellaneousCategory, TMyButton, 'Version');
5 end;
Search Delphi help for more information about other overloaded versions of this
function.
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
inspector.
6 interface7 8 TMyCategory = class(TPropertyCategory)
9 public10 classfunction Name: string; override;
11 end;
12 13 implementation14 15 classfunction TMyCategory.Name: string;
16 begin17 Result := 'My Category';
18 end;
19 20 //Then we could use our new category. 21 22 procedureregister;
23 begin24 RegisterComponents('Samples', [TMyButton]);
25 RegisterPropertyInCategory(TMyCategory, TMyButton, 'Version');
26 end;
You can also use RegisterPropertiesInCategory to register more than one property with one category at a time.