Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
EDIT:

Question is reduced and optimized in response to community's comments. The deleted part of the question will be posted as separate question.

QUESTION:

Is there any WM_SOMETHING or NM_SOMETHING message in Win32 API that can inform me about user changing the locale?

You see, I could use that message/notification to change my program's locale to the current locale, so _wtof_l can perform proper conversion.

Something like this pseudo-code:
C++
case WM_SOMETHING: // in my main window procedure
    _wsetlocale( LC_ALL, L"" );

Also, if there is such message, and I process it as in the pseudo-code above, will it adjust only main window's locale or will it also set locale for child dialog boxes and controls?.

MY EFFORTS TO SOLVE THIS:

After browsing through Internet, the only thing I found was WM_SETTINGCHANGE, WM_INPUTLANGCHANGE and WM_INPUTLANGCHANGEREQUEST messages, but I have never used them and do not know if they can solve my problem.

Thank you.

Best regards.
Posted
Updated 2-Feb-14 9:23am
v3
Comments
H.Brydon 1-Feb-14 17:34pm    
The obvious answer is to write a short program that will dump out a trace message for each of the above messages... and change the locale on the machine. [without looking] I'm sure that Google might give some useful info too... (or try Bing)
AlwaysLearningNewStuff 1-Feb-14 17:40pm    
Mr.Brydon,

First off, thank you for replying to my post.

I use pure Win32 API, I am a beginner and have never used trace messages.

If I have understood you well, you are just saying that I should have some kind of indication mechanism when I receive those messages?

Something like:

case WM_SETTINGCHANGE:
MessageBox( NULL, L"Test", L"Test", MB_OK );


Is that what you have meant? Am I understanding you right?

Thank you.

Best regards.
H.Brydon 1-Feb-14 17:45pm    
Okay, or look at documentation on ATLTrace2() and TRACE() or OutputDebugString()... These all display info in the output window when you run your program in the IDE.
AlwaysLearningNewStuff 1-Feb-14 18:09pm    
That is a start I guess. Thank you for your advice. Best regards.
Sergey Alexandrovich Kryukov 1-Feb-14 19:25pm    
This is exactly what you can use. This message is broadcasted to all the applications handling it as soon as the user modifies any changes.
—SA

1 solution

First of all, I would not talk about locale. This is old, obsolete notion created before Unicode and the notion of system and thread culture, which is kept for backward compatibility reasons. I would try to avoid dealing with locales at all. Instead, you should only look at the cultures.

Please see my comment to the question. I think you should really use the events you discovered and listed in your question.

—SA
 
Share this answer
 
Comments
AlwaysLearningNewStuff 1-Feb-14 19:42pm    
Thank you for your help Mr.Krukov-my 5 for the advice!

After reading through documentation of WM_SETTINGCHANGE I have realized
I could make a static global variable and update it in response to this message.

It could solve the problem with using proper locale in dialog boxes.

Still, I have another problem described above-say my app collects data and forms SQL query in EN-US (INSERT INTO table VALUES(1.2);). Before user clicks on "Save" he changes locale to EN-CA and only then clicks "Save". Now I get the query with 1.2 instead of 1,2 as argument and get error.

How could I solve that case? I can not stop user from changing locale until my query executes so I must adapt to this case. Any thoughts?

Maybe I am just too paranoid and too careful I guess ( after all, what kind of a person would leave a program running just to change the control panel settings? ) but I just want to be "on the safe side".

I will officially accept this as soon as I implement it, please be patient.

Thank you.

Best regards.
Sergey Alexandrovich Kryukov 1-Feb-14 19:46pm    
This would be a separate question, I think.
—SA
Garth J Lancaster 1-Feb-14 19:56pm    
+5 for your handling of this Sergey - It was a good jog to my memory to not think about 'locale' but 'culture' as well ... 'g'
Sergey Alexandrovich Kryukov 1-Feb-14 20:55pm    
Thank you, Garth.
—SA
Sergey Alexandrovich Kryukov 2-Feb-14 15:24pm    
Hm... in what context is this code fragment written? If you have to add code samples, could you do it in the body of your question, using "Improve question". There you could format it better...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900