RAD Studio |  |

Declaring the Property Type

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.

Copy Code

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

Copy Code

    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.

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