visual c++ - How to specify negative range for slider control? -
i developing mfc based sdi vc++ application. in application need specify negative range value slider control. minimum range slider -40 , maximum range 255. tried using setrange function. not working. how can set range in slider?please help..
my code slider follows: slider declared
csliderctrl m_ctrlectslider;
oninitialupdate function contains
m_ctrlectslider.setrangemin(-40); int ivalmin = m_ctrlectslider.getrangemin(); m_ctrlectslider.setrangemax(255); int ivalmax = m_ctrlectslider.getrangemax(); m_ctrlectslider.setpos(0); setdlgitemint( idc_ect_value, m_ctrlectslider.getpos(), false); setdlgitemint( idc_min_ect, ivalmin, false); setdlgitemint( idc_max_ect, ivalmax, false);
onbnclickedset function contains
int nmin = getdlgitemint(idc_min_ect, 0, false); int nmax = getdlgitemint(idc_max_ect, 0, false); m_ctrlectslider.setrange(nmin, nmax); m_ctrlectslider.setpos(nmin); int pos = m_ctrlectslider.getpos(); setdlgitemint(idc_ect_value, m_ctrlectslider.getpos(), false); m_ctrlectslider.redrawwindow();
here problem value returned during debugg correct. when comes ui on running min value 429496 , not -40 in edit box..why so..i developing sdi application using cformview class..
thanks in advance.
your minimum value '-40'which signed integer , treating unsigned integer last parameter of 'setdlgitemint' , 'getdlgitemint' method 'false'. that's why getting wrong value in place of '-40'. use following code correct behavior.
//for setting value
setdlgitemint( idc_ect_value, m_ctrlectslider.getpos(), true);
setdlgitemint( idc_min_ect, ivalmin, true);
setdlgitemint( idc_max_ect, ivalmax, true);
// getting value use follows
int nmin = getdlgitemint(idc_min_ect, 0, true);
int nmax = getdlgitemint(idc_max_ect, 0, true);
you can use link http://msdn.microsoft.com/en-us/library/c7t43w0s%28v=vs.90%29.aspx more details.
Comments
Post a Comment