Home Component Writing

Using some kind of "Global component" to influence total report behaviour

edited January 2010 in Component Writing
Hi

I'm trying to figure out a way to create a component i can drop on a report
template that will have influence on the entire report.

I.e. to create some kind of alternating grey-band in the background for detail,
groupheader and groupfooter bands. As the header and footer band are not
always visible, and the number of details within a group can be odd or even,
printing of the shading in i.e the groupfooter is dependent on the last band
that was printed before it.

I don't want to hardcode this into the report, but have all functionality
in the component itsself

How can I get the report to initiate some kind of init-routine of the component
when starting to print? Again, i dont want to hard code a call to the init
method from the OnReportPRint event?

Anyother clever ideas maybe on accomplishing this?

thanks
bas

Comments

  • edited January 2010
    Hi Bas,

    Unfortunately Report components do not function the way you need them to as
    stated in your requirements below. Once a component is placed on a report,
    nothing occurs until the engine is ready to print the band and therefore
    give commands to render the component.

    Another approach would be to perhaps loop through all report components
    before the report prints to see if your custom component is present. If so,
    it could trigger some event code that alters the report globally. This
    would need to be done before the report prints to have an effect on the
    entire report.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2010
    Hello Nico,

    Thanks for your answer, but i'm not giving up just yet :-)

    I'm trying right now to get the following construction to work.

    I'v created a new TDrawLineShading Component, derived from TppCustomGraphic
    This component is a Designtime only component, visualized by a simple (fixed
    size) bitmap when added to the report (derived from TppDesignControl).
    The component has properties Brush, Pen and a new one called ShadingInterval.

    A TppDrawCommand derivative is created for this component that has an empty
    Draw() procedure, just returning True.
    I'v overridden the StartOfMainreport procedure, which creates runtime TppShapes
    on the GroupFooter, GroupHaeder Detailband, with the brush and pen properties
    of the TDRawLineShading component. These shapes cover the entire band and
    are SendToBack. The OnPrint event of these TppShapes calls a method of TDrawLineShading,
    which increments a counter in TDrawLineShading and sets the visible property
    of the shape if "it is time to print a shading line"

    I do have a number of questions ...

    - Will this work?
    - Should i Derive the TDrawLineShading component from TppCustomGraphic or
    from somewhere higher in the class-hierarchy (like TppRelative) as this component
    itsself will never be printed?
    - Does it have consequences to create and add the TppShape components from
    within the StartOfMainReport procedure?
    - Any other suggestions about this ?

    thanks
  • edited January 2010
    Just an update on this subject.

    it seems i've got it to work like i detailed out earlier, with the small
    modification of intializing the shape components in the TDrawLineSHading.Init
    method instead of the StartOfMainreport

    gr
    bas
This discussion has been closed.