标签:size hue bre log 窗口 ide dct ges getline
在MFC中滑动条(CSliderCtrl)是个经常使用的控件,使用方法例如以下:
主要要方法有:
1、设置、取得滑动范围:
 void SetRange( int nMin, int nMax, BOOL bRedraw = FALSE ); 
void GetRange( int& nMin, int& nMax ) const;
 
2、设置、取得按下左右箭头滑动间隔:
 int SetLineSize( int nSize ); 
int GetLineSize( ) const;
 
3、设置、取得按下PgUp、PgDown时滑动间隔:
 int SetPageSize( int nSize ); 
int GetPageSize( ) const;
 
4、设置、取得滑块位置:
 void SetPos( int nPos ); 
int GetPos( ) const;
 
5、设置滑动条刻度的频度:
void SetTicFreq( int nFreq );
实例:
在对话框中放一个Slider控件。加入对应的Ctrl型变量为m_slider。在对话框初始化函数OnInitDialog()中加入:
 BOOL CDlgSetup::OnInitDialog() 
{
 CDialog::OnInitDialog();
 
 // TODO: Add extra initialization here
m_slider.SetRang(0,100);//设置滑动范围
 m_slider.SetTicFreq(10);//每10个单位画一刻度
 return TRUE;  // return TRUE unless you set the focus to a control
               // EXCEPTION: OCX Property Pages should return FALSE
}
 
 Slider控件本身并没有响应滑动的消息函数,但能够通过主窗口的OnHScroll()响应。
在类向导中为对话框加入WM_HSCROLL消息,在响应函数中加入:
 void CDlgSetup::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
 // TODO: Add your message handler code here and/or call default
 CSliderCtrl   *pSlidCtrl=(CSliderCtrl*)GetDlgItem(IDC_SLIDER1);
 m_int=pSlidCtrlHue->GetPos();//取得当前位置值  
  CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
//m_int 即为当前滑块的值。
 
标签:size hue bre log 窗口 ide dct ges getline
原文地址:http://www.cnblogs.com/jzssuanfa/p/6849954.html