Hi,
I've 2 sliders in my program to do panning for the X & Y axis respectively.
The slider (Horizontal) controlling the panning for X-axis works fine. But the slider (vertical) controlling the panning for Y-axis does not work.
m_sliderHorizontal.SetBuddy(&m_ChartCtrl, FALSE);
m_slidervertical.SetBuddy(&m_ChartCtrl, FALSE);
m_sliderHorizontal.SetRange(nMinX, nMaxX); m_slidervertical.SetRange(nMinY, nMaxY);
m_sliderHorizontal.SetTicFreq(1);
m_slidervertical.SetTicFreq(1);
m_sliderHorizontal.SetPos(0);
m_slidervertical.SetPos(m_nSliderVert);
void CDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
int nCurPos = m_sliderHorizontal.GetPos();
double Shift = m_dMinX - (double)nCurPos;
m_dSliderMinXShift = m_dMinX - Shift;
m_dSliderMaxXShift = m_dMaxX - Shift;
m_pBottomAxis->SetZoomMinMax(m_dSliderMinXShift, m_dSliderMaxXShift);
SetMinMax();
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
int nCurPos = m_slidervertical.GetPos();
double Shift = (double)(m_nSliderVert + nCurPos);
m_dSliderMinYShift = m_dMinY - Shift;
m_dSliderMaxYShift = m_dMaxY - Shift;
m_pLeftAxis->SetZoomMinMax(m_dSliderMinYShift, m_dSliderMaxYShift);
SetMinMax(); CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
The horizontal slider works fine. The vertical slider, however, does not works the same as the horizontal slider. Whenever i dragged the vertical slider, the Min & Max values of the Y-axis will get smaller if its in the negative range, bigger if in the positive range. It will never go back to the original range.
Example:
When i drag the slider up, the graphs and axis will move downwards and the Min and max values of Y-axis will keep getting bigger. Than when i start to drag down even to the end of the slider control, it never go back to the original range. When i drag it back up again, the Min & Max values gets even bigger.
What i want to do is that when i drag the vertical slider up, the axis together with the graphs should be moving downwards which is accomplished by the function SetZoomMinMax() within the original range.
Hope i make my question clear. Pardon my bad English.
Thanks for helping!