Writing the Implementation Method

From RAD Studio
Jump to: navigation, search

Go Up to Determining What to Draw


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:

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;
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
  }
}