Spin Control用法
时间:2025-04-20
时间:2025-04-20
Control用法
Spin Control用法
1>首先给该控件关联一个变量(Control类型的)m_Spin
2>在使用前先通过属性对话框修改它的部分属性
Alignment 属性共有3个选项Unattached,Left,Right Align,按自己的爱好选一个,决定SPIN是在右边还在左边;
Arrow Key, 设置为TRUE 时,当 FOCUS 在SPIN 上时,可以通过键盘上的上下键对其进行操作,为FALSE时则不可以
Wrap, 设为TRUE 时,当超过范围时,则进行回绕,为FALSE时.......
Auto Buddy,为TRUE 时,它将把它的下一个控件自动设为自己的BUDDY,当为FALSE时我们,可以通过SetBuddy(CWnd*)为其设定一个BUDDY ! SetIntBuddy,设为TRUE时,它将把伙伴控件值设为整数.
3>常用属性
a.设定 / 获取 SPIN的范围
m_Spin.SetRange(short min,short max);
m_Spin.SetRange32(int min,int max);
m_Spin.GetRange(short & min,short & max);
m_Spin.GetRange32(int & min ,int & max);
b.设置 / 获取当前显示的数据
m_Spin.SetPos(int pos);
m_Spin.SetPos32(int pos);
int pos = m_Spin.GetPos();
int pos = m_Spin.GetPos32(LPBOOL lpbError = NULL );//A pointer to a boolean value that is set to zero if the value is successfully retrieved or non-zero if an error occurs. If this parameter is set to NULL, errors are not reported.
c.设定 / 获取 当前的伙伴关系(BUDDY)
m_Spin.SetBuddy(CWnd * );//(CWnd * GetDlgItem(ID))
CWnd * m_hwnd = m_Spin.GetBuddy();
e. 设定 / 获取 当前BUDDY 里是按几进制显示的(10 , 16)
m_Spin.SetBase(n);// n 仅为10 或16;
CSpinButtonCtrl *pSpin=(CSpinButtonCtrl*) GetDlgItem(IDC_SPIN1);
pSpin-> SetRange(0,100); //Adjust These Values
pSpin-> SetBuddy(GetDlgItem(IDC_EDIT1);
Mapping The Message;
afx_msg void OnVScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar );
{
if (nSBCode == IDC_SPIN1)
{
Set Edit Value;
}
}
下一篇:签单顾客统计表