Home Component Writing

How to write TppDBText descendant which positions iself during report generation

edited August 2002 in Component Writing
Hi!

I want to write TppDBText descendant which positions itself relative to
another TppCustomText component. So I added published property as

property LeftComponent: TppCustomText read FLeftComponent write
SetLeftComponent;

and ovverrided various methods which looked like right ones (not much in
help about how to write RB components or for what various
methods/propertys are for :( ) but none worked as I want...

Basically, I need to calculate new position for my component when it's
value changes or when linked component's (LeftComponent) value changes.
So, question is, which methods are fired when one of those events occur?


TIA
ain

Comments

  • edited August 2002
    You'll have to create a wrapper component, that can reposition these two
    controls using the TextWidth + offset of the left component.

    Or, you may be able to use the detail band's before print event to
    pregenerate the band using you own "engine." Your engine will need to
    cacluate the area used by each component. Then you can use this info to
    determine the postition of the controls relative to the other because you
    know how much space they will need. Once you calculate how you want the
    controls to appear using your engine, then reposition the controls in the
    detail band and let the report generate the band normally.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited August 2002

  • edited September 2002
    By wrapper, I meant that you could create a component that would appear to
    be two components on the form, but really it would be one component. The
    two components could show a link between them. By clicking on the little
    link, you could show a dialog to select and connect the two datafields to
    this component. Then the component could generate a single draw command to
    the device. Getting a single draw command to the device would be the best
    bet to have the final result look the best on any device.

    Instead of a wrapper, there is a different approach. Use a band object loop
    technique to find the component which is left of the component to be
    shifted. You'll have to add and use a threshold property to check the top
    property of each component to build a list of possible left components. Then
    loop through these finding the one with the left that is closest to the left
    value you have without going over that value. Since a component has a band
    property, you can use this to loop through the objects in the same band. You
    are going to be limited to one shifting component with this approach. I
    haven't tried it but it should be possible. The problem is that any
    autosizing of the resulting draw commands is handled by the device. You may
    see artifacts related to this.

    The printing of the dotted or dashed pen is a limitation of the driver. It
    will only print as a line.

    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.