I made this simple code to reproduce a bug :
Code: Select all
void __fastcall TscrTestGraphe::Button2Click(TObject *Sender)
{
TChart * Chart1 = new TChart(this);
Chart1->Parent = this;
Chart1->Align = alClient;
TSubChartTool *SubChart1 = new TSubChartTool(NULL);
Chart1->AddSeries(new TPointSeries(Chart1))->FillSampleValues();
Chart1->Tools->Add(SubChart1);
TChart * Chart2 = SubChart1->Charts->AddChart("MySubChart");
// Chart2->Parent = _subChartTool->ParentChart;
Chart2->AddSeries(new TPointSeries(Chart1))->FillSampleValues();
TMarksTipTool *marksTipTool = new TMarksTipTool(Chart2);
marksTipTool->OnGetText = OnGetMarksTipGetText;
Chart2->Tools->Add(marksTipTool);
}
void __fastcall TscrTestGraphe::OnGetMarksTipGetText(TMarksTipTool* Sender, System::UnicodeString &Text)
{
TChartSeries *serie = Sender->ParentChart->Series[0];
int iValueIndex = serie->GetCursorValueIndex(); // <= Launch the exception
}
At run time, calling the GetCursorValueIndex function generates the exception "Le projet TEST.exe a déclenché la classe d'exception EInvalidOperation avec le message 'Le contrôle 'MySubChart' n'a pas de fenêtre parente'."
If I enable the line :
Code: Select all
Chart2->Parent = _subChartTool->ParentChart;
I have no exception but the tip is not displayed.
How to view a Tip on a sub chart ?
Thanks.