class ITChartControl : public CXTPChartControl { protected : DECLARE_MESSAGE_MAP() afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); afx_msg void OnRButtonUp(UINT nFlags, CPoint point); afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); }; typedef struct { NMHDR hdr; // NMHDR structure that contains additional information about this notification. ITChartControl* pControl; // Pointer to control that caused the event. UINT nFlags; CPoint point; } NMHDRCHARTCONTROL, FAR* LPNMHDRCHARTCONTROL; BEGIN_MESSAGE_MAP(ITChartControl, CXTPChartControl) ON_WM_LBUTTONDBLCLK() ON_WM_RBUTTONUP() ON_WM_MOUSEWHEEL() END_MESSAGE_MAP() BOOL ITChartControl::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { return CXTPChartControl::OnMouseWheel(nFlags, -zDelta, pt); // Inverse Zoom ! } void ITChartControl::OnLButtonDblClk(UINT nFlags, CPoint point) { CXTPChartControl::OnLButtonDblClk(nFlags, point); NMHDRCHARTCONTROL notify; notify.hdr.hwndFrom = m_hWnd; notify.hdr.code = NM_DBLCLK; notify.hdr.idFrom = GetDlgCtrlID(); notify.nFlags = nFlags; notify.point = point; notify.pControl = this; GetOwner()->SendMessage(WM_NOTIFY, (WPARAM)notify.hdr.idFrom, (LPARAM)¬ify); } void ITChartControl::OnRButtonUp(UINT nFlags, CPoint point) { CXTPChartControl::OnRButtonUp(nFlags, point); NMHDRCHARTCONTROL notify; notify.hdr.hwndFrom = m_hWnd; notify.hdr.code = NM_RCLICK; notify.hdr.idFrom = GetDlgCtrlID(); notify.nFlags = nFlags; notify.point = point; notify.pControl = this; GetOwner()->SendMessage(WM_NOTIFY, (WPARAM)notify.hdr.idFrom, (LPARAM)¬ify); } ... // Handling message in view containing chart control
BOOL ITChartView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { NMHDR* pnmhdr = (NMHDR*)lParam;
if (pnmhdr && pnmhdr->code == NM_DBLCLK) { NMHDRCHARTCONTROL *pnmhdrEx = (NMHDRCHARTCONTROL *) pnmhdr; CXTPChartElement* hit = m_wndChartControl.HitTest(pnmhdrEx->point); if (hit) { // Bla bla } } return CXTPResizeFormView::OnNotify(wParam, lParam, pResult); }
Thx for poor documentation, poor sample and no answer. L.
|