Page 1 of 1

Repeatedly create Series at Runtime

Posted: Tue May 03, 2022 6:46 am
by 16591355
Hello,
i'm using C++ Builder 10.4.2 with the classic compiler for my 32 bit application. In this application i have a Main Form and a Secondary Form that has a Chart with between 2 to 5 TFastLine Series, the user get to decide the number of Serie and data is different everytime. So everytime the user opens the Secondary Form i need to populate the Chart with these Series, and so everytime the Secondary Form closes i need to free and remove the Series. My code:

Code: Select all

//---------------------------------------------------------------------------
void __fastcall SecondaryForm::FormShow(TObject *Sender)
{
 TFastLineSeries *Sc;
 Chart->Canvas->ReferenceCanvas->Pen->OwnerCriticalSection = NULL;
 for(k=0; k<nSeries; k++)
 { 
 Chart->AddSeries(new TFastLineSeries(Chart)); 
 Sc = dynamic_cast<TFastLineSeries*>(Chart->Series[k]);
 Sc->ParentChart = Chart;
        
 //instruction to speed-up
 Sc->LinePen->Width = 0;
 Sc->LinePen->OwnerCriticalSection = NULL;

 //other code that populate the Series with dynamic array method

}
//---------------------------------------------------------------------------
void __fastcall SecondaryForm::FormClose(TObject *Sender, TCloseAction &Action)
{
      Chart->SeriesList->Clear();   //free and remove Series ??
}
My question is: am i doing right with the code? i have some runtime errors and i think the error may come from this code.

Re: Repeatedly create Series at Runtime

Posted: Wed May 18, 2022 4:45 pm
by yeray
Hello,

Sorry for the late reply here.
I've done a simple example project to test this and it seems to work without errors for me in RAD 11.1, both with the new and the classic compiler.
CleanSeriesCBuilder.zip
(9.42 KiB) Downloaded 467 times
Please, give it a try at the project above and let us know if it works fine for you.