手机版

Spin Control用法

时间:2025-04-21   来源:未知    
字号:

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;

}

}

Spin Control用法.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)