RAD Studio |  |

Writing the Implementation Method

When the read or write part of a property definition uses a method instead of directly accessing the stored property data, you need to implement the method.

Add the implementation of the SetShape method to the implementation part of the unit:

Copy Code

    procedure TSampleShape.SetShape(Value: TSampleShapeType);
    begin
      if FShape <> Value then                           { ignore if this isn"t a change }
      begin
        FShape := Value;                                { store the new value }
        Invalidate;                                     { force a repaint with the new shape }
      end;
    end;

Copy Code

    void __fastcall TSampleShape::SetShape(TSampleShapeType Value)
    {
      if (FShape != Value)             // ignore if this isn't a change
      {
         FShape = Value;               // store the new value
         Invalidate();                 // force a repaint with the new shape
      }
    }

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!