如題 chart 上有若干個點,這些點連接起來構成一條曲線,
如何通過點擊來獲取 被點擊的點的x y 值
uj5u.com熱心網友回復:
在界面獲取滑鼠的x值,跟你的日期對應,然后在曲線上取相應日期的y值。uj5u.com熱心網友回復:
不能直接選取點嗎uj5u.com熱心網友回復:
我也只是給你提供一個思路,具體該怎么做你自己想。你需要在滑鼠點擊一個點時,得到XY,那么你就要讓程式知道你滑鼠點的是哪個點,所以,你就要去獲取你滑鼠當前的X值,然后得到點,再得到Y值。只是思路,不知道對你有沒有用。或者有大神可以提供好回答。uj5u.com熱心網友回復:
上面我說的,估計難點的就是得到當前滑鼠的X值。這個你可以去查一查怎么得,只要得到了X值,剩下的就超級簡單了。uj5u.com熱心網友回復:
void CChartCtrl::OnLButtonDown(UINT nFlags, CPoint point){
SetCapture();
if (m_bZoomEnabled)
{
m_bLMouseDown = true;
m_rectZoomArea.TopLeft() = point;
m_rectZoomArea.BottomRight() = point;
}
if (m_PlottingRect.PtInRect(point))
{
TCursorMap::iterator iter = m_mapCursors.begin();
for (iter; iter!=m_mapCursors.end(); iter++)
iter->second->OnMouseButtonDown(point);
Invalidate();
}
/////添加
CString str;
//string sstr= ("點下左鍵時,滑鼠處于x=%d,y=%d的位置", point.x, point.y);
//str = _T("點下左鍵時,滑鼠處于x=%d,y=%d的位置", point.x, point.y);
SendMouseEvent(CChartMouseListener::LButtonDown, point);
CWnd::OnLButtonDown(nFlags, point);
}
CChart里面有個滑鼠點擊函式,里面的point.x, point.y就是滑鼠點擊的坐標,可以根據滑鼠點擊的位置與曲線位置之間進行換算得到曲線坐標
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/85048.html
標籤:VB.NET
