Spin Control 和 Slider Control 的用法



Spin Control:

 Spin Control比较简单,简单介绍消息处理如下:

afx_msg void OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult);
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, &CMy2005DlgDlg::OnDeltaposSpin1)
void CMy2005DlgDlg::OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult)
{
 LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
 // TODO: 在此添加控件通知处理程序代码
 *pResult = 0;
}

点击上下箭头时,可根据pNMUpDown的内容判定用户的操作,含义如下:

typedef struct _NM_UPDOWN {
  NMHDR hdr;
  int iPos;
  int iDelta;
} NMUPDOWN, FAR* LPNMUPDOWN;
Members
hdr 
NMHDR structure that contains additional information about the message. 
iPos 
Signed integer value that represents the up-down control's current position. 
iDelta 
Signed integer value that represents the proposed change in the up-down control's position. 
  
Slider Control:

1)加入控件变量:
CSliderCtrl m_sliderCtrl; 
DDX_Control(pDX, IDC_SLIDER1, m_sliderCtrl);
2)事件处理
afx_msg void OnNMCustomdrawSlider1(NMHDR *pNMHDR, LRESULT *pResult);
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER1, &CMy2005DlgDlg::OnNMCustomdrawSlider1)
void CMy2005DlgDlg::OnNMCustomdrawSlider1(NMHDR *pNMHDR, LRESULT *pResult)
{
 LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
 // TODO: 在此添加控件通知处理程序代码
 int pos = m_sliderCtrl.GetPos();
 *pResult = 0;
}

3)常用控制

//Sets the range (minimum and maximum positions) for the slider in a slider control.
 m_sliderCtrl.SetRange(0,100,1);

//Sets the current position of the slider in a slider control.
 m_sliderCtrl.SetPos(20);

//Sets the position of a tick mark in a slider control.
     m_sliderCtrl.SetTic(30);

// Sets the frequency with which tick marks are displayed in a slider.
     m_sliderCtrl.SetTicFreq(10);

注意:要显示刻度线,Auto Ticks要为TRUE, Tick Marks要为TRUE

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值