Search code examples
c++mfclocale

MFC Dialog Data Exchange (DDX) comma instead point as decimal


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!


Solution

  • 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 and CListBox have a SetLocale method but I've never used it so not sure how well it works and it's not available on all controls.