当范围在-10到10之间时,CSliderCtrl,SetPos(0)不正确. [英] CSliderCtrl, SetPos(0) not correct when range is set between -10 to 10.

查看:60
本文介绍了当范围在-10到10之间时,CSliderCtrl,SetPos(0)不正确.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的程序中有一个垂直滑块控件.
当我将滑块的位置设置为零时.它应该在中间.

Hi,

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);
			
m_slidervertical.SetPos(0);



从-10到10的范围,中间应该为0.因此,当我将位置设置为0时,滑块应该位于中间.但是,它没有出现在中间.它显示在滑块的顶部.

有人可以向我解释为什么吗?



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?

推荐答案

那是因为您尚未为滑块控件设置Tic频率值.意味着您必须为滑块控件设置一个值,表示您的一个Tic可能会将控件移到一个位置.为此,请编写以下代码

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 );
m_slidervertical.SetPos(0);


这篇关于当范围在-10到10之间时,CSliderCtrl,SetPos(0)不正确.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆