最近在用TEECHART時有一個問題,我在一個子對話框中定義了一個teechart的變數:m_chart1,然后在同一個對話框中針對這個m_chart1定義了一個mousemove事件,滑鼠獲取到的坐標點是正確的,但是在運行的時候老是出現錯誤。下面是我的代碼
void CTchart1::OnMouseMove(UINT nFlags, CPoint point)
{
CLineGraph *pDlg=(CLineGraph *)AfxGetApp();
int mPoint = -1;
double xValue = ((CSeries)pDlg->m_chart1.Series(0)).XScreenToValue(point.x)+0.5;
mPoint = (int)(xValue);
if (mPoint < 0)
{
return;
}
CValueList xList = ((CSeries)pDlg->m_chart1.Series(0)).get_XValues();
CValueList yList = ((CSeries)pDlg->m_chart1.Series(0)).get_YValues();
CString strXLabel = ((CSeries)pDlg->m_chart1.Series(0)).get_PointLabel(mPoint);
int dYLabel = (int)yList.get_Value(mPoint);
CToolList tlist = (CSeries)pDlg->m_chart1.get_Tools();
CTools tools = tlist.get_Items(1);
CAnnotationTool anntool=tools.get_asAnnotation();
CString strTopNote;
strTopNote.Format("point.x=%d,point.y=%d",point.x, point.y);
anntool.put_Text(strTopNote);
CWnd::OnMouseMove(nFlags, point);
}
其中代碼運行到“double xValue = ((CSeries)pDlg->m_chart1.Series(0)).XScreenToValue(point.x)+0.5;”這一步就會出錯,我的直覺是用陳述句“CLineGraph *pDlg=(CLineGraph *)AfxGetApp();”來獲取子對話框中的類:ClineGraph的指標出錯了。但是正確的獲取子對話框的指標的方法我找到很久也沒有找到,大家知道這個是怎么處理的嗎?
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/125083.html
標籤:界面
