CSpinButtonCtrl::GetPos()和GetPos32( )两个函数的用法
2008-01-15 12:30
567 查看
CSpinButtonCtrl::GetPos()和GetPos32( )两个函数的用法
今天写了一个程序,里面的结果有点意思,在BOOL Cex06aDlg::OnInitDialog()中,使用了spinbutton控件
设置如下:
CSpinButtonCtrl *pSpin = (CSpinButtonCtrl *)GetDlgItem(IDC_SPIN1);
pSpin->SetRange(0, 100);
pSpin->SetPos(25);
//m_strMyedit = _T("25"); //.Format()
m_strMyedit.Format( _T("%3.1lf"), (double)pSpin->GetPos());
SetDlgItemText(IDC_BUDDY_SPIN1, m_strMyedit);
显示在文本编辑框里面的居然不是25.0,我之后还有一个消息函数,也是点击spinbutton控件来实现文本编辑诓的变化,如下:
void Cex06aDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
if (nSBCode == SB_ENDSCROLL)
return;
if (pScrollBar->GetDlgCtrlID() == IDC_SPIN1) {
CSpinButtonCtrl *pSpin = (CSpinButtonCtrl *)pScrollBar;
m_strMyedit.Format(_T("%3.1lf"), double(pSpin->GetPos()) );
SetDlgItemText(IDC_BUDDY_SPIN1, m_strMyedit);
}
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
结果都是从62256.0开始变化奇怪了,于是我便查msdn,关于这个函数的使用:
Retrieves the current position of a spin button control.
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.
The second version returns the 32-bit position.
这个一看就晓得了,GetPos32( )才可以实现32位的数据,而不带32的就只能得到16位,另外16就要问xp了,呵呵
把GetPos()改变为GetPos32( )一切ok啦。
不过在消息函数里面也可以不用上面的方法,用getbuddy()得到文本指针,再setwindowtext(m_strMystr)来显示。
今天写了一个程序,里面的结果有点意思,在BOOL Cex06aDlg::OnInitDialog()中,使用了spinbutton控件
设置如下:
CSpinButtonCtrl *pSpin = (CSpinButtonCtrl *)GetDlgItem(IDC_SPIN1);
pSpin->SetRange(0, 100);
pSpin->SetPos(25);
//m_strMyedit = _T("25"); //.Format()
m_strMyedit.Format( _T("%3.1lf"), (double)pSpin->GetPos());
SetDlgItemText(IDC_BUDDY_SPIN1, m_strMyedit);
显示在文本编辑框里面的居然不是25.0,我之后还有一个消息函数,也是点击spinbutton控件来实现文本编辑诓的变化,如下:
void Cex06aDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
if (nSBCode == SB_ENDSCROLL)
return;
if (pScrollBar->GetDlgCtrlID() == IDC_SPIN1) {
CSpinButtonCtrl *pSpin = (CSpinButtonCtrl *)pScrollBar;
m_strMyedit.Format(_T("%3.1lf"), double(pSpin->GetPos()) );
SetDlgItemText(IDC_BUDDY_SPIN1, m_strMyedit);
}
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
结果都是从62256.0开始变化奇怪了,于是我便查msdn,关于这个函数的使用:
Retrieves the current position of a spin button control.
int GetPos( ) const; int GetPos32( LPBOOL lpbError = NULL ) const; |
Parameters
lpbErrorA 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.
Return Value
The first version returns the 16-bit current position in the low-order word. The high-order word is nonzero if an error occurred.The second version returns the 32-bit position.
Remarks
When it processes the value returned, the control updates its current position based on the caption of the buddy window. The control returns an error if there is no buddy window or if the caption specifies an invalid or out-of-range value.Requirements
Header: afxcmn.h这个一看就晓得了,GetPos32( )才可以实现32位的数据,而不带32的就只能得到16位,另外16就要问xp了,呵呵
把GetPos()改变为GetPos32( )一切ok啦。
不过在消息函数里面也可以不用上面的方法,用getbuddy()得到文本指针,再setwindowtext(m_strMystr)来显示。
相关文章推荐
- CSpinButtonCtrl用法
- CSpinButtonCtrl(SPIN控件)用法
- CSpinButtonCtrl的用法
- CSpinButtonCtrl用法
- CSpinButtonCtrl用法
- 在VC中CSpinButtonCtrl用法,整理下来
- 易语言GetMessagePos函数用法获取上次鼠标消息坐标
- C++中关于cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
- 转:C++中cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
- *** $CI =& get_instance() 用法:关于CodeIgniter中get_instance() 函数
- PHP读写JSON文件以及jQuery的getJSON函数用法
- CSpinButtonCtrl的弱智问题
- cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
- FindWindow,GetActiveWindow函数用法
- CSpinButtonCtrl使用说明
- CSpinButtonCtrl使用说明
- cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
- bind1st和bind2nd这两个函数的用法。
- cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
- Windows硬件系统函数 - GetCursorPos