1

I'm defining my first components and I would like they can be configured using a TMyOptions class instance.

TMyCmp = class(TComponent)
protected
  FMyOptions : TMyOptions;
  ...
published
  property MyOptions : TMyOptions read FMyOptions write FMyOptions;
  ...
end;

Each component, in the constructor, creates an instance of TMyOptions that's defined like this example:

TMyOptions = class
protected
   FMyOption1 : boolean;
   FMyOption2 : boolean;
published
   property MyOption1 : boolean read FMyOption1 write FMyOption2;
   property MyOption2 : boolean read FMyOption2 write FMyOption2; 
end;

So, in the object inspector I can see TMyOptions but I can't change values. Could someone tell me which is the right way to achieve my goal? Thanks to everyone.

Hwau
  • 850
  • 3
  • 12
  • 23
  • 1
    Your property setter for `MyOptions` is no good. You need a setter method that assigns the state of the new value to the value owned by the `TMyCmp` instance. Which means `TMyOptions` derives from `TPersistent` and overrides `Assign`. Remy's answer at the dupe has all this detail. Start there. – David Heffernan Apr 09 '15 at 22:14
  • You're right! Thanks for your willingness! – Hwau Apr 10 '15 at 18:22

0 Answers0