I've created a TChart object dynamically with m_Chart1.Create.
I need to add an event handler in the code for MouseDown events.. How do I do this?
Adding MouseDown Event Handler to dynamically created TChart
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi nbp,
You should add a method like the one below at your unit:
Implement the method like this:
And finally assign the event to the chart:
You should add a method like the one below at your unit:
Code: Select all
procedure Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
Code: Select all
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
end;
Code: Select all
Chart1.OnMouseMove:=Chart1MouseMove;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Sorry, I should have posted this on the ActiveX forum. I have added the Tchart (ActiveX) component dynamically with mChart1.Create();
I'm using Visual C++ 6.0 and when I try to add the mouse event handler the way you describe,
mChart1.OnMouseMove = MyMouseMouseFunction;
I get an error saying " = overloaded operator" Do I need to do something different because I'm working with an ActiveX component? I read somewhere that I need to add the event sink map manually to my class??
--nbp
I'm using Visual C++ 6.0 and when I try to add the mouse event handler the way you describe,
mChart1.OnMouseMove = MyMouseMouseFunction;
I get an error saying " = overloaded operator" Do I need to do something different because I'm working with an ActiveX component? I read somewhere that I need to add the event sink map manually to my class??
--nbp
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi nbp,
We have looked at this. Unfortunately dynamically creating events in Microsoft's VC++ is somewhat beyond the scope of our experience. The issue would apply generically to any ActiveX Control so perhaps you might be able to obtain additional help on Microsoft public forums.
As a suggestion to a line of investigation please note that the standard way to setup the event would be via the EVENTSINK_MAP.
ie.
It may be possible to set the events once for IDC_TCHART and re-use the IDC_TCHART for your dynamic Charts as the setting can be programmatically
accessed:
eg.
Here you may be able to call and substitute m_ctrlChart for your dynamic instance of the Chart.
We have looked at this. Unfortunately dynamically creating events in Microsoft's VC++ is somewhat beyond the scope of our experience. The issue would apply generically to any ActiveX Control so perhaps you might be able to obtain additional help on Microsoft public forums.
As a suggestion to a line of investigation please note that the standard way to setup the event would be via the EVENTSINK_MAP.
ie.
Code: Select all
BEGIN_EVENTSINK_MAP(CDraggingDlg, CDialog)
ON_EVENT(CDraggingDlg, IDC_TCHART, 1 /*OnAfterDraw*/, OnAfterDrawTChart,
VTS_NONE)
END_EVENTSINK_MAP()
accessed:
eg.
Code: Select all
void CDraggingDlg::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDraggingDlg)
DDX_Control(pDX, IDC_TCHART, m_ctrlChart);
//}}AFX_DATA_MAP
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |