CSpinButtonCtrl::GetPos()和GetPos32( )两个函数的用法
来源:互联网 发布:devcpp for mac 编辑:程序博客网 时间:2024/05/20 13:05
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.
int GetPos( ) const;int GetPos32( LPBOOL lpbError = NULL ) const;
Parameters
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::GetPos()和GetPos32( )两个函数的用法
- CSpinButtonCtrl的用法
- CSpinButtonCtrl用法
- CSpinButtonCtrl用法
- CSpinButtonCtrl用法
- getPos
- getPos
- CSpinButtonCtrl(SPIN控件)用法
- Oracle lead 和 lga 两个函数的用途和用法
- Oracle lead 和 lga 两个函数的用途和用法
- bind1st和bind2nd这两个函数的用法。
- bind1st和bind2nd这两个函数的用法
- matlab中zeros 和 ones 这两个函数的用法
- C语言关于localtime_s()和asctime_s()两个函数的用法。
- 自己总结一下CSpinButtonCtrl用法
- CSpinButtonCtrl的使用
- CSpinButtonCtrl的弱智问题
- CSpinButtonCtrl的弱智问题
- Get Things Done--我的时间管理
- 隔岸观火
- ar进行信息输入和输入的一个细节问题
- C#中常用函数总结
- 我的智囊团(SSH)_mldn
- CSpinButtonCtrl::GetPos()和GetPos32( )两个函数的用法
- JavaScript脚本
- 关于Oracle中不能扩展Undo表空间的问题
- ASP.NET 2.0 本地化技术之研究(一)
- j2sdk_5_0.exe的使用
- ASP.NET 2.0 本地化技术之研究(二)
- ASP.Net本地化/国际化解决方案原理和代码示例
- 线程与进程的同步问题
- tomcat使用ldap验证