Repeatedly create Series at Runtime
Posted: Tue May 03, 2022 6:46 am
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:
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.
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 ??
}