Adding MouseDown Event Handler to dynamically created TChart

TeeChart for ActiveX, COM and ASP
Post Reply
nbp
Newbie
Newbie
Posts: 83
Joined: Mon Sep 18, 2006 12:00 am

Adding MouseDown Event Handler to dynamically created TChart

Post by nbp » Mon Mar 05, 2007 11:26 pm

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?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 06, 2007 10:01 am

Hi nbp,

You should add a method like the one below at your unit:

Code: Select all

    procedure Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
Implement the method like this:

Code: Select all

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin

end;
And finally assign the event to the chart:

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
Image Image Image Image Image Image
Instructions - How to post in this forum

nbp
Newbie
Newbie
Posts: 83
Joined: Mon Sep 18, 2006 12:00 am

Post by nbp » Tue Mar 06, 2007 3:15 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Mar 19, 2007 3:37 pm

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.

Code: Select all

BEGIN_EVENTSINK_MAP(CDraggingDlg, CDialog)
  ON_EVENT(CDraggingDlg, IDC_TCHART, 1 /*OnAfterDraw*/, OnAfterDrawTChart,
VTS_NONE)
END_EVENTSINK_MAP()
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.

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
}
Here you may be able to call and substitute m_ctrlChart for your dynamic instance of the Chart.
Best Regards,
Narcís Calvet / 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

Post Reply