Click here to Skip to main content
13,767,570 members
Rate this:
Please Sign up or sign in to vote.
See more:

I've a vertical slider control in my program.
When I set the position of my slider to be in the zero position. it should be in the middle.

m_slidervertical.SetBuddy(&m_ChartCtrl, FALSE);
m_slidervertical.SetRange(-10, 10);

The range from -10 to 10, the middle should be 0. So when i set the position to 0, the slider should be in the middle. However, it does not appear in the middle. It appears on the top of the slider.

Can anyone please explain to me why?
Posted 17-Apr-12 20:04pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

That is because you have not set a Tic frequency value for your slider control. Means you must set a value to the slider control saying that your one Tic may move the control to just one position. For that write the code as below

m_slidervertical.SetBuddy(&m_ChartCtrl, FALSE);
m_slidervertical.SetRange(-10, 10);
slidervertical.SetTicFreq( 1 );
skfoo1 18-Apr-12 1:49am
I see. Thanks for your help.

I've got another question related to the slider control.

int nMinY = floor(m_dMinY);
int nMaxY = ceil(m_dMaxY);
m_nSliderVert = ((nMaxY + nMinY) / 2); // Get the middle of the range
m_slidervertical.SetBuddy(&m_ChartCtrl, FALSE);
m_slidervertical.SetRange(nMinY, nMaxY);

void CDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)

int nEndVal = m_slidervertical.GetPos();
double Shift = (double)(m_nSliderVert + nEndVal);

m_dSliderMinYShift = m_dMinY - Shift; // m_dMinY = Current Min value of the Y-axis
m_dSliderMaxYShift = m_dMaxY - Shift; // m_dMaxY = Current Max value of the Y-axis

// Do Panning.
// Get Current Min & Max values of the Y-axes.

When ever i scroll up or down, the graphs will move. But after a while, the values of the Y-axis will be very large, and the graphs will be moved out of range. I've tried to use the original values of the Y-axis to calculate the shifting. But it can only works when the graphs are in the original state. If the graphs are zoomed-in, and the slider is dragged, the shifting is still using the original values which is wrong. It should be using the current Max & Min values of the Y-axis. How can i solve this problem? Hope I make the question clear. Pardon my bad English.
Resmi Anna 18-Apr-12 2:25am
Unfortunately i didnt get your question:(...Please mark the above question as solved and post the current question as a new one. So that everyone can view this and someone can help you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web01-2016 | 2.8.181116.1 | Last Updated 18 Apr 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100