New Blog Post: PDF/A and Metadata

How to find a component by its classname in a report

edited April 2016 in General
We derived TppDBCalcA as a sublass of TppDBCalc.
As we want to deprecate this component know, we would like
do disallow the user to insert it into reports.
For existing reports using this component, it still should be possible
to insert.

I now want to detect, where a report has a component of this classname
"TppDbCalcA". Is there a method or do i have to loop through all
elements within the report?

Tia Carsten

--


Hint: We altered the sources!Hint: We altered the sources!

Comments

  • edited April 2016
    Hi Carsten,

    There is no built-in function. A simple way to do this is to use the
    Form/DataModule that 'owns' the report, bands, components and iterate over
    the Components[ ] array.

    For liIndex := 0 to myReportForm.ComponentCount-1 do
    if myReportForm.Components[liIndex] is TppDbCalcA then
    // do something here


    You could use the above to implement function such as

    function ContainsClassType(aOwner: TComponent, aClassType: TClass); Boolean;




    Best regards,

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

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited April 2016
    Hi Nard,

    your solution sounds good, but i can find the component.
    my idea is to call a routine at the end of TppDesigner.SetReport.
    So I have aReport AS TppReport or self as TppDesigner.
    Unfortunately i could not find my component in any Components[].

    I am bit bit puzzled...

    Tia Carsten
    Nard Moseley (Digital Metaphors) schrieb am 07.04.2016 :

    --


    Hint: We altered the sources!Hint: We altered the sources!
  • edited April 2016
    Hi Carsten,

    Yes Report.Bands[ ].Objects[ ] is another valid approach.



    Best regards,

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

    Best regards,

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