Edward Huang asked:

> In object inspector, we can expand properties like 'Font', 'Constraints'
> etc, and set property for these objects.
>
> How can I let Delphi to expand my own object property like them?
> At moment, a customised object property comes up a dropdown box
> with no options to select.

I am presuming Delphi 5+, because this stuff gets really complex in Delphi 4
due to an unfortunate limitation of the old property editor code.

In any case all that you need to do is register a property editor for the
class that has this sub component using the TClassProperty property editor
defined in DsgnIntf along the lines of the following code:

uses
  DsgnUIntf.

procedure Register;
begin
  RegisterPropertyEditor(TypeInfo(TMySubClass), TMyMasterClass,
    'MySubClassPropertyName', TClassProperty);
end;

If you use the subclass in more than one place, or for more than one
property you can twiddle the above parameters to be more generous in the
internal matching when Delphi is looking for a property editor.

By default Delphi provides you with the standard TComponentProperty property
editor, which assumes that you want to have a component refered to, rather
than a actual component instance exposed.

For more fun and excitement I recommend reading DsgnIntf closely, or at
least the header portion.

Cheers, Max.


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to