Home Component Writing
New Blog Post: Email: Multi-Service

creating DBText-style component

edited August 2004 in Component Writing
Hi!

I'm trying to create a custom component, derived from a TppDBText component
for my end-users.

I want to paint the DBText background in the color specified in its field.
For example:

if the field value is clRed, the DBText will print in red.
Can you help me, please?

Thanks!

Comments

  • edited August 2004

    1. An example of a custom component can be found in RBuilder\Demos\RCL. The
    example is the Checkbox and DBCheckbox components. The code is commented.

    2. The source to DBText is located in ppCtrls.pas. This unit contains most
    of the basic controls such as Label and DBText. These both descend from a
    common ancestor class, TppCustomText. Therefore you could either descend
    from TppDBText or from TppCustomText.

    3. When a component generates on a page, it creates a DrawCommand object
    that describes what needs to be rendered. The TppCustomText class creates a
    TppDrawText draw command descendant. The PropertiesToDrawCommand method is
    used to set the properties of the draw command.

    4. The Text property of the TppCustomText calls the GetTheText method. The
    DBText class overrides this method to return the datafield value.


    Check the source code to the TppCustomText and TppDBText class.

    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.