MFC textbox和spin绑定后,编辑textbox中的数值,按spin可以继续增加减小

wohekenan 2015-09-08 01:12:18
如题,现在遇到了个问题,
例如,textbox中当前值是2,步长是3,我在textbox中把数值改成10后,按spin上键,
textbox中显示的是5,而不是13,请问各位大神这个问题应该如何解决啊

麻烦详细一点
...全文
134 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
信阳毛尖 2015-09-09
  • 打赏
  • 举报
回复
引用 6 楼 wohekenan 的回复:
[quote=引用 5 楼 lsq19871207 的回复:] 我更相信自己:添加UDN_DELTAPOS消息,在OnDeltaposSpin函数中自己去手动更新textbox的值
你好,如果我现在已经使用了ON_EN_KILLFOCUS(IDC_EDIT_H782B_VX_YQ, &CTabPscEo::OnEnKillfocusEditPscEo) 再添加DN_DELTAPOS消息消息处理,可以吗,这两个可以共存吗[/quote] 理论上是可以的呀,不过你添加ON_EN_KILLFOCUS做什么呢?我没这么用过,你添加DN_DELTAPOS消息试试,验证一下就知道了
wohekenan 2015-09-08
  • 打赏
  • 举报
回复
引用 5 楼 lsq19871207 的回复:
我更相信自己:添加UDN_DELTAPOS消息,在OnDeltaposSpin函数中自己去手动更新textbox的值
你好,如果我现在已经使用了ON_EN_KILLFOCUS(IDC_EDIT_H782B_VX_YQ, &CTabPscEo::OnEnKillfocusEditPscEo) 再添加DN_DELTAPOS消息消息处理,可以吗,这两个可以共存吗
信阳毛尖 2015-09-08
  • 打赏
  • 举报
回复
我更相信自己:添加UDN_DELTAPOS消息,在OnDeltaposSpin函数中自己去手动更新textbox的值
赵4老师 2015-09-08
  • 打赏
  • 举报
回复
其实我也没具体解决过类似问题,只不过隐约觉得和这些API有关。 等楼下真正VC/MFC大神指点迷津中…… 楼主还可以 MSDN98_1.ISO http://pan.baidu.com/s/1dDF41ix, MSDN98_2.ISO http://pan.baidu.com/s/1bnGo0Vl 先下载安装MSDN98 再参考其中相关例子代码。
wohekenan 2015-09-08
  • 打赏
  • 举报
回复
引用 2 楼 zhao4zhong1 的回复:
CWnd::UpdateData BOOL UpdateData( BOOL bSaveAndValidate = TRUE ); Return Value Nonzero if the operation is successful; otherwise 0. If bSaveAndValidate is TRUE, then a return value of nonzero means that the data is successfully validated. Parameters bSaveAndValidate Flag that indicates whether dialog box is being initialized (FALSE) or data is being retrieved (TRUE). Remarks Call this member function to initialize data in a dialog box, or to retrieve and validate dialog data. The framework automatically calls UpdateData with bSaveAndValidate set to FALSE when a modal dialog box is created in the default implementation of CDialog::OnInitDialog. The call occurs before the dialog box is visible. The default implementation of CDialog::OnOK calls this member function with bSaveAndValidate set to TRUE to retrieve the data, and if successful, will close the dialog box. (If the Cancel button is clicked in the dialog box, the dialog box is closed without the data being retrieved.) CWnd Overview | Class Members | Hierarchy Chart See Also CWnd::DoDataExchange
请问应该在哪个事件处理函数里添加这个方法, 我现在text和spin的具体实现方式是, 编辑testbox内容后,按tab键,调用的处理函数是 ON_EN_KILLFOCUS(IDC_EDIT_H782B_VX_YQ, &CTabPscEo::OnEnKillfocusEditPscEo) 在OnEnKillfocusEditPscEo函数中将编辑的内容转换成spin对应的步数, 但是,如果我编辑textbox后,直接按所绑定的spin的话,就不会调用OnEnKillfocusEditPscEo函数, 直接处理onScroll()函数。
赵4老师 2015-09-08
  • 打赏
  • 举报
回复
CWnd::UpdateData BOOL UpdateData( BOOL bSaveAndValidate = TRUE ); Return Value Nonzero if the operation is successful; otherwise 0. If bSaveAndValidate is TRUE, then a return value of nonzero means that the data is successfully validated. Parameters bSaveAndValidate Flag that indicates whether dialog box is being initialized (FALSE) or data is being retrieved (TRUE). Remarks Call this member function to initialize data in a dialog box, or to retrieve and validate dialog data. The framework automatically calls UpdateData with bSaveAndValidate set to FALSE when a modal dialog box is created in the default implementation of CDialog::OnInitDialog. The call occurs before the dialog box is visible. The default implementation of CDialog::OnOK calls this member function with bSaveAndValidate set to TRUE to retrieve the data, and if successful, will close the dialog box. (If the Cancel button is clicked in the dialog box, the dialog box is closed without the data being retrieved.) CWnd Overview | Class Members | Hierarchy Chart See Also CWnd::DoDataExchange
赵4老师 2015-09-08
  • 打赏
  • 举报
回复
TextBox.DataChanged=True

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧