您的位置:首页 > 其它

Spin控件/CSpinButtonCtrl 修改为上增下减

2013-08-21 10:29 176 查看
参考:http://msdn.microsoft.com/en-us/library/windows/desktop/bb759903(v=vs.85).aspxhttp://hi.baidu.com/s025037/item/e06fdcf71c7c3149932af2d2

 

1. 首先,Spin控件的使用:只要把对应的edit框的tab顺序调到它之前即可完成关联。

 

2. 通常Spin控件的工作模式 是 点击 上(up) 减小;  点击  下(down) 增加,见csdn中的SetRange说明:缺省(Min = 100, Max 0,所以是逆序的,上减下增) 

Note
The default range for the spin button has the maximum set to zero (0) and the minimum set to 100. Because the maximum value is less than the minimum value, clicking the up arrow will decrease the position and clicking the down arrow will increase it. UseCSpinButtonCtrl::SetRange
to adjust these values.

 

3. 这和我们通常使用的习惯不同,解决起来比较简单:

(推荐)一种常用方法:设置一下正向的范围即可:

((CSpinButtonCtrl*)GetDlgItem(IDC_Spin))->SetRange(1,1000);

 

另一种方法:响应点击事件,然后把iDelta设置为其负值即可实现,这个使用的效果是"负负得正",我们知道有这个方法,但不推荐使用

void CDlg::OnDeltaposSpin(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
if (pNMUpDown != NULL)
{
pNMUpDown->iDelta = -pNMUpDown->iDelta;
}
*pResult = 0;
}


 

 Owed by: 春夜喜雨 http://blog.csdn.net/chunyexiyu  转载请标明来源 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: