MFC 对话框数据交换 (DDX) 逗号代替小数点
为了初始化对话框中的控件并收集用户输入,我使用 DDX。如何更改程序以使用逗号而不是点显示浮点数(最好不更改区域设置)?
该程序设置了“C”语言环境,如果我更改语言环境,我必须注意每个 atof、sprintf 操作(用于获取/设置浮点数的库,在底层 mysql 数据库中,需要带有小数点的字符串作为点)。
到目前为止,我只想更改语言环境,然后将 stringstream 与 imbue 一起使用(在 此处< /a>),但也许有机会不更改语言环境。
感谢您的帮助!
To initialize the controls in my dialogs and to gather user input, I'm using DDX. How can I change the program to display float numbers with a comma instead of a point (best without changing the locale)?
The program has the "C" locale set, if I change the locale, I have to take care on every atof, sprintf operation (the library for get-/setting the float numbers, in the underlying mysql database, expects strings with the decimal as point).
So far, I only think of changing the locale and then use stringstream with imbue (found here), but maybe there's a chance without changing the locale.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个特定于区域设置的事情,您可能需要使用区域设置来处理它的更改。
请注意,DDX 用于初始化控件对象,以便您的控件变量成员声明与您在资源文件中选择的值或在初始化控件所在的对话框时所做的任何操作保持同步。
编辑:一些控件如
CComboBox
和CListBox
有一个SetLocale
方法,但我从未使用过它,所以不确定它的工作原理,但它不是可用于所有控件。This is a locale specific thing you probably will need to handle the changing of it using locale.
Note that DDX is for initializing control objects so that your control variable member declarations stay in sync with the values you chose in your resource file or whatever you did when initializing the dialog the controls reside on.
Edit: Some controls like
CComboBox
andCListBox
have aSetLocale
method but I've never used it so not sure how well it works and it's not available on all controls.