I seem to be able to handle click events and recognize which Chart Control component I am clicking. But, when ever I click the ConstantLine component I don't seem to be able to recognize it. I am using the below code to as a proof of concept in order to test being able to register a click on different components:
void CLineView::OnChartClick(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/){
CPoint cursorPoint;
GetCursorPos(&cursorPoint);
m_wndChartControl.ScreenToClient(&cursorPoint);
CXTPChartElement* chartElement = m_wndChartControl.HitTest(cursorPoint);
CXTPChartTitleCollection* titleCollection = m_wndChartControl.GetContent()->GetTitles();
CString text = "Default Text";
if (titleCollection->GetCount() == 0)
titleCollection->Add(new CXTPChartTitle());
if (DYNAMIC_DOWNCAST(CXTPChartSeries, chartElement)){
CXTPChartSeries* series = (CXTPChartSeries*)chartElement;
text = series->GetName();
} else if (DYNAMIC_DOWNCAST(CXTPChartAxisConstantLine, chartElement)){
CXTPChartAxisConstantLine* trackLine = (CXTPChartAxisConstantLine*)chartElement;
text = "Success";
} else if (DYNAMIC_DOWNCAST(CXTPChartLegend, chartElement)){
CXTPChartLegend* trackLine = (CXTPChartLegend*)chartElement;
text = "Legend";
}
titleCollection->GetAt(0)->SetText(text);
}
My ultimate goal is to be able to register a click on the constant line and then be able to drag it across a chart in order to get the x,y values of a series at the constant line.
|