Declaring the Property Type

From RAD Studio
Jump to: navigation, search

Go Up to Determining What to Draw


When you declare a property of a user-defined type, you must declare the type first, before the class that includes the property. The most common sort of user-defined type for properties is enumerated.

For the shape control, you need an enumerated type with an element for each kind of shape the control can draw.

Add the following type definition above the shape control class's declaration.

 type
   TSampleShapeType = (sstRectangle, sstSquare, sstRoundRect, sstRoundSquare,
     sstEllipse, sstCircle);
   TSampleShape = class(TGraphicControl) { this is already there }
 enum TSampleShapeType { sstRectangle, sstSquare, sstRoundRect, sstRoundSquare, sstEllipse, sstCircle };
 class PACKAGE TSampleShape : public TGraphicControl         // this is already there

You can now use this type to declare a new property in the class.