Dear sir/madam
How do I zoom and unzoom from code using visual c++
Regards
JB
Zoom and unzoom
Re: Zoom and unzoom
Hi jacques,
Here it is:
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |