TfrxReport destroys all Components after print() is called

edited August 2014 in FastReport 4.0
Hello,
I am trying to write CONSOLE tool that is used to generate PDFs from FR layouts. The idea is that I have layouts containing TADOQuery object to recieve data. I dont want all the output in one PDF file so each record is picked in TADOQuery with query->Filter and query->Filtered = true. This query is found by method findReportQuery
TfrxADOQuery* ReportHelper::findReportQuery(TComponent* frxPoint)
{
    if(frxPoint == NULL) return NULL;
    try
    {
        const int COMPONENT_NUMBER = frxPoint->ComponentCount;
        for(int index = 0; index < COMPONENT_NUMBER; ++index)
        {
            TfrxComponent* component   = dynamic_cast<TfrxComponent*>(frxPoint->Components[index]);
            if(component == NULL)continue;

            TComponent* parent = dynamic_cast<TComponent*>(frxPoint->Components[index]);
            TfrxADOQuery* query;

            if((parent != NULL) && (parent->ComponentCount > 0))
            {
                query = findReportQuery(parent);
                if(query != NULL) return query;
                else continue;
            }

            query = dynamic_cast<TfrxADOQuery *>(component);
            if(query != NULL) return query;
        }
    }
    catch(...){}
    return NULL;
}

The problem is that after Print() is called and findReportQuery gets called again for second record the frxPoint->ComponentCount returns 2 instead of 20 and no query is found. Our company has software using FR4 which generates the reports in exactly that way, but the ADOQuery can be found after each print, but I cannot find a thing that I make differently.

Also I am preparing the connection in my custom FrxReport
CustomReport::CustomReport(TADOConnection* connection) : Frxclass::TfrxReport(NULL)
{
    mAdoComponents = new TfrxADOComponents(this);
    mAdoComponents->DefaultDatabase = connection;
    
    this->Script->Parent = fsGlobalUnit();
    this->Script->AddMethod
    (
        "function SetDataMatrixBarcode(msg : String, pictureObject : String, ModulSize : Integer, Margin : Integer) : Boolean",
        scriptMethodHandler
    );

}

Any ideas what I am doing wrong?

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.