Mirror

Adding published properties to forms and datamodules (Views: 102)


Problem/Question/Abstract:

When I add published properties to a form / datamodule decendent, what don't I see them is the object inspector?

Answer:

In order to see properties of decendent forms / datamodules in the object inspector, we need three actions:

1. Define the property as published, with a type the object inspector can handle. Note that the object inspector does not handle interface types (in delphi 5).

TMyForm = class(TForm)
published
  property MyProp: Integer;
end;

2. Add a register procedure to some unit ( I recomend another unit, that will be included only in design-time package ).

// for TForm decendents:

procedure Register;
begin
  RegisterNoIcon([TMyForm]);
  RegisterCustomModule(TMyForm,
    TCustomModule);
end;

// for TDataModule decendents:

procedure Register;
begin
  RegisterNoIcon([TMyForm]);
  RegisterCustomModule(TMyForm,
    TDataModuleDesignerCustomModule);
end;

the class TDataModuleDesignerCustomModule is in the DMDesigner unit, for which we have no source. The unit is in the dsnide50.bpl. In order to use this unit we have to include the dsnide50.bpl package in our's package 'Requires'. As this package is used only by the delphi IDE, I recommend to add it only to a design-time packages.

3. Compile and install the new package. Now we will see the new property in the object inspector.

<< Back to main page