2007. október 11., csütörtök
Categories in the Object Inspector
Problem/Question/Abstract:
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.
procedure Register;
begin
RegisterComponents('Samples', [TMyButton]);
RegisterPropertyInCategory(TMiscellaneousCategory, TMyButton, 'Version');
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.
interface
TMyCategory = class(TPropertyCategory)
public
class function Name: string; override;
end;
implementation
class function TMyCategory.Name: string;
begin
Result := 'My Category';
end;
Then we could use our new category.
procedure Register;
begin
RegisterComponents('Samples', [TMyButton]);
RegisterPropertyInCategory(TMyCategory, TMyButton, 'Version');
end;
You can also use RegisterPropertiesInCategory to register more than one property with one category at a time.
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése