Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Incrementing slider control values in 0.01 step

126 views
Skip to first unread message

Lucress Carol

unread,
Apr 11, 2012, 7:57:00 AM4/11/12
to
Hi every one,
I can not figure out how i can increment the value of my slider
control in 0.01 step. What's happening is that the step seems to be
0.08 instead of 0.01

BOOL CTestDlg:: OnInitDialog()
{
...
m_Slider.SetRange(0,1000); // from 0 to 10
m_Slider.SetTicFreq(1);
SetDlgItemText(IDC_SLIDER_VALUE, _T("0"));
}

void CTestDlg:: OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*
pScrollbar)
{
m_SliderValue.Format(_T("%.2f"),(m_Slider.GetPos())*0.01);
SetDlgItemText(IDC_SLIDER_VALUE, m_SliderValue);
}

Could someone tell me what i'm overlooking ?
Thank you

scot...@mvps.org

unread,
Apr 11, 2012, 8:33:08 AM4/11/12
to
The slider control moves in units of pixels. If the size in pixels is less than the range you want (1000) then moving by one pixel has to change the reported position by more than 1.

In your case it looks like the slider is only 125 pixels long. So moving it by 1 pixel changes the reported position by (1000/125).

Lucress Carol

unread,
Apr 11, 2012, 8:47:48 AM4/11/12
to
> In your case it looks like the slider is only 125 pixels long. So moving it by 1 pixel changes the reported position by (1000/125).- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Thank you
0 new messages