TfrxReport destroys all Components after print() is called
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
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
Any ideas what I am doing wrong?
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?