Similar to the way you add functions to Designer, you can also define your own object types and register them in List & Label. The user can access the new objects in the usual way on the left toolbar and menu.
Here there is also a special component for adding objects:
After adding this component to your form, you can define the properties of the new object in the Properties window of the component. The table provides an overview:
Property |
Description |
Name |
The unique name of the object. |
Description |
This description appears in the Designer. It is allowed to contain spaces but should not be more than 30 characters long. |
Icon |
The icon of the object that will be shown in the toolbar and menu in the Designer. It should be a 16x16 pixel icon. |
The component has three types of events. First, the OnInitialCreation event is triggered when the user creates a new object. If desired, you can have an initial dialog appear on the user's screen. For example, this can be a wizard that helps the user to more easily configure the new object. If it is not necessary to use this in a particular case, simply skip handling the event.
The following lines initialize the object as soon as the new object is placed on the workspace for the first time.
Delphi:
procedure
TDesExtForm.GradientFillObjectInitialCreation(Sender:
TObject;
ParentHandle:
Cardinal);
begin
with Sender as
TLl29XObject do
begin
Properties.AddProperty('Color1',
'255');
Properties.AddProperty('Color2',
'65280');
end;
end;
The OnEdit event is triggered when the user double-clicks the newly inserted object or selects "Properties" from the context menu.
After you are finished editing the object, you are prompted by List & Label to show the object. The OnDraw event is triggered for this purpose. The event arguments are responsible for generating the TCanvas as well as a TRect for the object. Using the usual methods, you can now draw in the workspace. Here, of course, it is also possible or useful to access the stored object properties.