Zoom and unzoom

TeeChart for ActiveX, COM and ASP
Post Reply
jacques
Newbie
Newbie
Posts: 30
Joined: Thu Nov 20, 2008 12:00 am
Location: South Africa
Contact:

Zoom and unzoom

Post by jacques » Fri Feb 05, 2010 9:50 am

Dear sir/madam

How do I zoom and unzoom from code using visual c++

Regards
JB

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

Re: Zoom and unzoom

Post by Yeray » Fri Feb 05, 2010 12:12 pm

Hi jacques,

Here it is:

Code: Select all

//...
int MouseDownX, MouseDownY, MouseActX, MouseActY;

BOOL CV8ExampleDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// ...
	
	m_Chart1.AddSeries(scPoint);
	m_Chart1.Series(0).FillSampleValues(25);
	m_Chart1.GetZoom().SetEnable(false);	
	MouseDownX = -1;
	MouseDownY = -1;

	return TRUE;  // return TRUE  unless you set the focus to a control
}

//...

void CV8ExampleDlg::OnAfterDrawTchart1() 
{	
	if ((MouseDownX>-1) && (MouseDownY>-1))
	{
		m_Chart1.GetCanvas().GetBrush().SetStyle(1);
		m_Chart1.GetCanvas().Rectangle(MouseDownX,MouseDownY,MouseActX,MouseActY);
	}
}

void CV8ExampleDlg::OnMouseDownTchart1(long Button, long Shift, long X, long Y) 
{
	MouseDownX = X;	
	MouseDownY = Y;
}

void CV8ExampleDlg::OnMouseUpTchart1(long Button, long Shift, long X, long Y) 
{
	if ((MouseActX>MouseDownX) && (MouseActY>MouseDownY))
	{
		m_Chart1.GetAxis().GetBottom().SetMinMax(m_Chart1.GetAxis().GetBottom().CalcPosPoint(MouseDownX),m_Chart1.GetAxis().GetBottom().CalcPosPoint(MouseActX));
		m_Chart1.GetAxis().GetLeft().SetMinMax(m_Chart1.GetAxis().GetLeft().CalcPosPoint(MouseDownY),m_Chart1.GetAxis().GetLeft().CalcPosPoint(MouseActY));
	}
	else
	{
		m_Chart1.GetAxis().GetBottom().SetAutomatic(true);
		m_Chart1.GetAxis().GetLeft().SetAutomatic(true);
	}

	MouseDownX = -1;	
	MouseDownY = -1;
}

void CV8ExampleDlg::OnMouseMoveTchart1(long Shift, long X, long Y) 
{
	MouseActX = X;
	MouseActY = Y;
	
	m_Chart1.GetEnvironment().InternalRepaint();
}
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