开发者

need some help in making slider control

开发者 https://www.devze.com 2023-01-05 07:25 出处:网络
i have made the slider control in c++ using MFC. there is my code. void CImageAnalyserDlg::OnHScroll(UINT nSBCode, UINT nPo开发者_开发知识库s, CScrollBar* pScrollBar)

i have made the slider control in c++ using MFC. there is my code.

void CImageAnalyserDlg::OnHScroll(UINT nSBCode, UINT nPo开发者_开发知识库s, CScrollBar* pScrollBar)
{

 if(nSBCode == SB_THUMBPOSITION) 
 { 
 slidervalue.Format(_T("%d"), nPos);
 UpdateData(false);
 }
 else 
 { 
 CDialog::OnHScroll(nSBCode, nPos, pScrollBar); 
 } 
}

every thing is done, i just wanna know where should i write the implementaion of slider control, i mean where should i write this

if(slidervalue="10")
{
//do something
}


Why would you want to put the slider position into a string and compare it at some other place in your code? In the OnHScroll handler, you already got the slider position. Do whatever you want to do in that function, or call some other function from the handler.


You can add an integer variable 'slidervalue' to your slider and set its max and min values to 100 and 0 respectively. Instead of reading the nPos parameter you can read this variable easily.

 void CImageAnalyserDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)

{
   UpdateData(TRUE);
   if(slidervalue==10)
   {
   //do something
   }
}

Hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消