Dispatch IDs for events generated by TChart

TeeChart for ActiveX, COM and ASP
Post Reply
nbp
Newbie
Newbie
Posts: 24
Joined: Tue Apr 28, 2015 12:00 am

Dispatch IDs for events generated by TChart

Post by nbp » Mon Jul 27, 2015 11:07 pm

I am trying to add an OnAfterDraw event to my TChart that is placed on my form at runtime. I want to add an OnAfterDraw method. Where can I find the dispatch ID of the OnAfterDraw event so I can add the event handler? In the past I have added handlers for OnMouseDown, OnMouseUp and OnMouseMove with IDs 19, 21 and 20 respectively. It was a while ago and can't recall where I got these IDs as well as the list of paramenters (VTS_XX) . e.g. here is the snippet of code I used before where the ControlIDs for the added charts start at 99:

Code: Select all

BEGIN_EVENTSINK_MAP(CPageDlg, CPropertyPage)
    //{{AFX_EVENTSINK_MAP(CPltPage)
    ON_EVENT_RANGE(CPageDlg, 99, 200, 19 /* OnMouseDown */, OnMouseDownTchart1, VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4)
    ON_EVENT_RANGE(CPageDlg, 99, 200, 20 /* OnMouseMove */, OnOnMouseMoveTchart1, VTS_I4 VTS_I4 VTS_I4 VTS_I4)
    ON_EVENT_RANGE(CPageDlg, 99, 200, 21 /* OnMouseUp */, OnOnMouseUpTchart1, VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4)
    //}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Dispatch IDs for events generated by TChart

Post by Sandra » Tue Jul 28, 2015 2:47 pm

Hello nbp,

The codes below, show you how can initialize the events in the VC++6 and in the Visual C++.

If you work in VC++6 you should initialize the events in same way below:

Add in the .h application class

Code: Select all

 afx_msg void OnAfterDrawTChart();
Add in the .cpp application class
Initialize event

Code: Select all

BEGIN_EVENTSINK_MAP(CProjectName, CDialog)
    //{{AFX_EVENTSINK_MAP(CProjectName)
    ON_EVENT(CProjectName, IDC_TCHARTName, 1 /* OnAfterDraw */, OnAfterDrawTChart, VTS_NONE)
    ON_EVENT(CProjectname, IDC_TCHARTName, 19 /* OnMouseDown */, OnMouseDownTChart, VTS_I4 VTS_I4 VTS_I4 VTS_I4)
    ON_EVENT(CProjectName, IDC_TCHARTName, 20 /* OnMouseMove */, OnMouseMoveTchart, VTS_I4 VTS_I4 VTS_I4)
    ON_EVENT(CProjectName, IDC_TCHARTName, 21 /* OnMouseUp */, OnMouseUpTchart, VTS_I4 VTS_I4 VTS_I4 VTS_I4)
    //}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
Event

Code: Select all

void ClassName::OnAfterDrawTChart()
{
}
If you work in Visual C++, you should initialize events in same way below
Add in the .h application class

Code: Select all

   void OnAfterDrawTchart1();
Add in the *.cpp application class
Initialize event

Code: Select all

BEGIN_EVENTSINK_MAP(CColorMap, CDialogEx)
    ON_EVENT(CClassName, IDC_ChartName,1, CClassName::OnAfterDrawTchart1, VTS_NONE)
END_EVENTSINK_MAP()
Event

Code: Select all

void CColorMap::OnAfterDrawTchart1()
{
    // TODO: Add your message handler code here
}

We hoping the codes above help you to fix the problem you are experiencing.


Thanks in advance
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

nbp
Newbie
Newbie
Posts: 24
Joined: Tue Apr 28, 2015 12:00 am

Re: Dispatch IDs for events generated by TChart

Post by nbp » Wed Jul 29, 2015 4:15 pm

Yes. That helps. But the OnDraw() Event is not happening when I expect it to.

Under what circumstances does OnDraw() happen?

For instance, sometimes my chart is displayed with custom axis in the wrong position but after a few seconds it redraws with the axis is the correct position. Sometimes OnDraw() is invoked when I move my mouse cursor out of the window or even within the window but not always. Something quirky is going on.

nbp
Newbie
Newbie
Posts: 24
Joined: Tue Apr 28, 2015 12:00 am

Re: Dispatch IDs for events generated by TChart

Post by nbp » Wed Jul 29, 2015 4:17 pm

Also, where can I find the documentation that associates the Event ID with the Event? Is it included anywhere in the TChart help files or tutorials?

Marc
Site Admin
Site Admin
Posts: 1209
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Dispatch IDs for events generated by TChart

Post by Marc » Thu Jul 30, 2015 2:49 pm

Hello,

Please note that the event name in the example is OnAfterDraw(), not OnDraw().

TeeChart includes paint (draw) events at different moments of the Chart render cycle, OnAfterDraw is, as the name implies, triggered after the Chart has rendered, allowing a custom drawn object to be rendered on top of chart contents.

If you want to provoke a calculation of chart elements upon which to base a custom draw or position (custom axis position for example), then you can use the Chart Repaint() method, it could be placed in the mousemove event if you are processing information there and want to provoke a recalculation of Chart contents.

Tutorial 13 describes a little how the Chart canvas is accessible via the Draw events, and the draw order.
If you look at the help topic for iTChart in the TeeChart library helpfile you will see a list of all Chart events. The event list is visible in Visual Studio if you right mouseclick on the Chart and select 'Add Event Handler'.

I hope that may be of help.
Regards,
Marc Meumann
Steema Support

nbp
Newbie
Newbie
Posts: 15
Joined: Fri Apr 01, 2016 12:00 am

Re: Dispatch IDs for events generated by TChart

Post by nbp » Tue Oct 18, 2016 8:44 pm

How can I add an event for the OnSeriesClick Event? i.e. I need the Dispatch ID for this event and the line to add for the event handler inside of the BEGIN_EVENTSINK_MAP and END_EVENTSINK_MAP with the reference to my earlier post in this thread.

i.e. what would be the line for the OnSeriesClick event?

ON_EVENT(CProjectName, IDC_TCHARTName, DispatchID? /* OnSeriesClick *,?????????????????????)


Regards
nbp

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Dispatch IDs for events generated by TChart

Post by Yeray » Wed Oct 19, 2016 10:04 am

Hello,
nbp wrote:i.e. what would be the line for the OnSeriesClick event?

ON_EVENT(CProjectName, IDC_TCHARTName, DispatchID? /* OnSeriesClick *,?????????????????????)
Here it is:

Code: Select all

ON_EVENT(CProjectName, IDC_TCHARTName, 7  /* OnClickSeries */, OnClickSeriesTChart, VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4)
I think this is the complete list:

Code: Select all

	ON_EVENT(CProjectName, IDC_TCHARTName, 19 /* OnMouseDown */, OnMouseDownTChart, VTS_I4 VTS_I4 VTS_I4 VTS_I4)
	ON_EVENT(CProjectName, IDC_TCHARTName, 1  /* OnAfterDraw */, OnAfterDrawTChart, VTS_NONE)
	ON_EVENT(CProjectName, IDC_TCHARTName, 29 /* OnBeforeDrawSeries */, OnBeforeDrawSeriesTChart, VTS_NONE)
	ON_EVENT(CProjectName, IDC_TCHARTName, 30 /* OnBeforeDrawAxes */, OnBeforeDrawAxesTChart, VTS_NONE)
	ON_EVENT(CProjectName, IDC_TCHARTName, 3  /* OnClick */, OnClickTChart, VTS_NONE)
	ON_EVENT(CProjectName, IDC_TCHARTName, 4  /* OnClickAxis */, OnClickAxisTChart, VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4)
	ON_EVENT(CProjectName, IDC_TCHARTName, 5  /* OnClickBackground */, OnClickBackgroundTChart, VTS_I4 VTS_I4 VTS_I4 VTS_I4)
	ON_EVENT(CProjectName, IDC_TCHARTName, 6  /* OnClickLegend */, OnClickLegendTChart, VTS_I4 VTS_I4 VTS_I4 VTS_I4)
	ON_EVENT(CProjectName, IDC_TCHARTName, 7  /* OnClickSeries */, OnClickSeriesTChart, VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4)
	ON_EVENT(CProjectName, IDC_TCHARTName, 8  /* OnDblClick */, OnDblClickTChart, VTS_NONE)
	ON_EVENT(CProjectName, IDC_TCHARTName, 10 /* OnDragOver */, OnDragOverTChart, VTS_I4 VTS_I4 VTS_I4 VTS_PBOOL)
	ON_EVENT(CProjectName, IDC_TCHARTName, 11 /* OnEndDrag */, OnEndDragTChart, VTS_I4 VTS_I4)
	ON_EVENT(CProjectName, IDC_TCHARTName, 12 /* OnEnter */, OnEnterTChart, VTS_NONE)
	ON_EVENT(CProjectName, IDC_TCHARTName, 13 /* OnExit */, OnExitTChart, VTS_NONE)
	ON_EVENT(CProjectName, IDC_TCHARTName, 14 /* OnGetAxisLabel */, OnGetAxisLabelTChart, VTS_I4 VTS_I4 VTS_I4 VTS_PBSTR)
	ON_EVENT(CProjectName, IDC_TCHARTName, 16 /* OnGetLegendRect */, OnGetLegendRectTChart, VTS_PI4 VTS_PI4 VTS_PI4 VTS_PI4)
	ON_EVENT(CProjectName, IDC_TCHARTName, 18 /* OnGetNextAxisLabel */, OnGetNextAxisLabelTChart, VTS_I4 VTS_I4 VTS_PR8 VTS_PBOOL)
	ON_EVENT(CProjectName, IDC_TCHARTName, 20 /* OnMouseMove */, OnMouseMoveTChart, VTS_I4 VTS_I4 VTS_I4)
	ON_EVENT(CProjectName, IDC_TCHARTName, 21 /* OnMouseUp */, OnMouseUpTChart, VTS_I4 VTS_I4 VTS_I4 VTS_I4)
	ON_EVENT(CProjectName, IDC_TCHARTName, 22 /* OnPageChange */, OnPageChangeTChart, VTS_NONE)
	ON_EVENT(CProjectName, IDC_TCHARTName, 23 /* OnResize */, OnResizeTChart, VTS_NONE)
	ON_EVENT(CProjectName, IDC_TCHARTName, 24 /* OnScroll */, OnScrollTChart, VTS_NONE)
	ON_EVENT(CProjectName, IDC_TCHARTName, 25 /* OnStartDrag */, OnStartDragTChart, VTS_NONE)
	ON_EVENT(CProjectName, IDC_TCHARTName, 31 /* OnTimerTChart */, OnTimerTChart, VTS_NONE) 
	ON_EVENT(CProjectName, IDC_TCHARTName, 26 /* OnUndoZoom */, OnUndoZoomTChart, VTS_NONE)
	ON_EVENT(CProjectName, IDC_TCHARTName, 27 /* OnZoom */, OnZoomTChart, VTS_NONE)
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply