Thread View: borland.public.cppbuilder.nativeapi
8 messages
8 total messages
Started by rogo
Thu, 29 Nov 2007 23:36
Change locale settings.
Author: rogo
Date: Thu, 29 Nov 2007 23:36
Date: Thu, 29 Nov 2007 23:36
8 lines
1196 bytes
1196 bytes
Can anybody tell me why the below wont set a euro pc that using a comma for decimal places change to a dot.. SetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SDECIMAL,"."); i did read that i should post a WM_SETTINGSCHANGE message but cant find a declaration anywhere.? Thanks in advance.
Re: Change locale settings.
Author: rogo
Date: Thu, 29 Nov 2007 23:40
Date: Thu, 29 Nov 2007 23:40
3 lines
888 bytes
888 bytes
The Pc in question is being used under winXP Thanks
Re: Change locale settings.
Author: Bob Gonder
Date: Fri, 30 Nov 2007 00:38
Date: Fri, 30 Nov 2007 00:38
14 lines
1426 bytes
1426 bytes
rogo wrote: >Can anybody tell me why the below wont set a euro pc that using a comma for >decimal places change to a dot.. > >SetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SDECIMAL,"."); Did you check the return value? >i did read that i should post a WM_SETTINGSCHANGE message but cant find a >declaration anywhere.? See answer here... http://blogs.msdn.com/michkap/archive/2006/05/21/603374.aspx
Re: Change locale settings.
Author: rogo
Date: Fri, 30 Nov 2007 08:01
Date: Fri, 30 Nov 2007 08:01
41 lines
2218 bytes
2218 bytes
It is returning a value >0 so i am assuming it supposed to be working, but i
have a euro friend that says it doesn't..
here's the actual code i am using.
SetToDecimal check is done on opening the app.
usingeuro determines whether the SetToComma function is called on closing
app.
void __fastcall TMainForm::SetToDecimal(void)
{
char buff [100];
GetLocaleInfo(MAKELCID(MAKELANGID(LANG_NEUTRAL,
SUBLANG_NEUTRAL),SORT_DEFAULT),
LOCALE_SDECIMAL,buff,100);
if(StrPas(buff) == ",")
{
if(!SetLocaleInfo(MAKELCID(MAKELANGID(LANG_NEUTRAL,
SUBLANG_NEUTRAL),SORT_DEFAULT),
LOCALE_SDECIMAL,"."))
ShowMessage("Unable to set correct decimal settings.");
SendMessage (HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);
usingeuro = true;
}
}
void __fastcall TMainForm::SetToComma(void)
{
char buff [100];
GetLocaleInfo(MAKELCID(MAKELANGID(LANG_NEUTRAL,
SUBLANG_NEUTRAL),SORT_DEFAULT),
LOCALE_SDECIMAL,buff,100);
if(StrPas(buff) == ".")
{
SetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SDECIMAL,",");
usingeuro = false;
}
SendMessage (HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);
}
thanks
Re: Change locale settings.
Author: Asger Joergensen
Date: Fri, 30 Nov 2007 10:14
Date: Fri, 30 Nov 2007 10:14
31 lines
1847 bytes
1847 bytes
Hi rogo rogo says: > It is returning a value >0 so i am assuming it supposed to be working, but i > have a euro friend that says it doesn't.. I can confirm that it is not working ! You find the ',' alright and You also broadcast, because all my windows are jumping, but it doesn't change the value. I don't know how to fix it Your way, but I would like to ask You if You realy think this is the best way ? What if Your customer have other appclication that rely on the system locale to be what it is, I can mention that my PC Bank probably wouldn't work if I were to switch ',' with '.'. I usually replace the character between the Edit fields and the "Amarican" calculating functions that way my app's everywhere at least when it comes to currrency. And I would get quite anoid if an appclication were to switch '.' and ',' without me asking for it. Kind regards Asger
Re: Change locale settings.
Author: rogo
Date: Fri, 30 Nov 2007 10:53
Date: Fri, 30 Nov 2007 10:53
4 lines
1174 bytes
1174 bytes
Problably best to replace any euro commas in the costs values with a dot as their typed then.? Thanks
Re: Change locale settings.
Author: Asger Joergensen
Date: Fri, 30 Nov 2007 13:10
Date: Fri, 30 Nov 2007 13:10
40 lines
1930 bytes
1930 bytes
Hi rogo
rogo says:
> Problably best to replace any euro commas in the costs values with a dot as
> their typed then.?
Maybe, if You can get it to work You can change
the key value in the keypress but people can paste
and then You would have to do it in the on change
event and would you then change valuses already
changed back, all kind of troubles..;-)
You set a bool in the app to true if Euro;
and then You just have a function like this when You
asign numbers to and from the editfields.
char* __fastcall SwitchDotsAndCommas(char* Str, bool Euro)
{
if(! Euro)return Str;
char *Scr = Str;
while(*Scr != '\0')
{
if(*Scr == ',')*Scr = '.';
else if(*Scr == '.')*Scr = ',';
++Scr;
}
return Str;
}
//-------------------------------------------------
Just let the user do what they do and see what they want
to see.
Kind regards
Asger
Re: Change locale settings.
Author: rogo
Date: Mon, 03 Dec 2007 12:56
Date: Mon, 03 Dec 2007 12:56
3 lines
1268 bytes
1268 bytes
That is the way i went in the end, just a slightly different version.. Thanks again for your continued help.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads