How to force a refresh of CurrentUICulture and CurrentCulture

G

Guest

Hi,

I want to force the application thread to refresh its CurrentCulture and
CurrentUICulture according to the system settings while the application is
running.

I made a class based on Microsoft.WindowsCE.Forms.MessageWindow which traps
the WM_SETTINGCHANGE message and raises an event. When the application
executes the event, I want to force the culture refreshment there. I put a
MessageBox to see if it works, and my MessageWindow based class works well.
If I open the Regional Settings control panel and I change the date or time
format, my application receives the WM_SETTINGCHANGE message correctly.

How can I force the current application thread to use the new system
settings without having to restart the application?

Thank you!
 
D

Daniel Moth

Stop and think about your end goal and what you'll have to do to achieve it.

If the user changes the OS language, detecting that, and loading any new
text with the new language is one part of the story. Your forms are already
loaded displaying some (e.g. English) text; You'll have to change the text
for all those UI elements (effectively reloading them).

Why not just restart your app? That is the expected/default/recommended
behaviour - anything else and you are hacking towards a more complex
solution with little benefit... my £0.02

Cheers
Daniel
 
G

Guest

To give you some hints, maybe it's important to know that my application has
to communicate with hardware (read "slow electronic devices") at startup, and
actually, with a 432 MHz PXA270, it take around 12 to 15 seconds to start the
application. It already too long, that why I don't want to restart.

Now, what I want is to display the date and time in the correct format. If a
user changes the language, it's OK for me to ask him to restart, this is
required by the OS anyway. But if he changes the date format, he shouldn't
have to reboot just for that! Actually, I display the date using the
DateTime.Now.ToShortDateString().

Do you see what I mean?

Thanks a lot!
--
Léo Gagné
EXFO Electro-Optical Engineering Inc.


Daniel Moth said:
Stop and think about your end goal and what you'll have to do to achieve it.

If the user changes the OS language, detecting that, and loading any new
text with the new language is one part of the story. Your forms are already
loaded displaying some (e.g. English) text; You'll have to change the text
for all those UI elements (effectively reloading them).

Why not just restart your app? That is the expected/default/recommended
behaviour - anything else and you are hacking towards a more complex
solution with little benefit... my £0.02

Cheers
Daniel
 
D

Daniel Moth

Now that you have explained a bit more about your problem (rather than what
you think the solution should be) we can give you more specific advice.

DateTime.ToString has an overload that takes a IFormatProvider object as an
argument. You can create a CultureInfo object for the locale you are
interested in (so there is no need to change the threadculture which is not
supported anyway). For more on this read here:
http://www.danielmoth.com/Blog/2004/11/cultureinfo.html

Alternatively, you might be able to dig in the framework and find where the
locale info is cached and then use reflection to change that. A previous
example that does that for the timezone (which is also not changeable
without an app restart) is here:
http://groups-beta.google.com/group...frm/thread/6a4d531b89a6d3e9/f268e47830080f83?

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Leo Gagne said:
To give you some hints, maybe it's important to know that my application
has
to communicate with hardware (read "slow electronic devices") at startup,
and
actually, with a 432 MHz PXA270, it take around 12 to 15 seconds to start
the
application. It already too long, that why I don't want to restart.

Now, what I want is to display the date and time in the correct format. If
a
user changes the language, it's OK for me to ask him to restart, this is
required by the OS anyway. But if he changes the date format, he shouldn't
have to reboot just for that! Actually, I display the date using the
DateTime.Now.ToShortDateString().

Do you see what I mean?

Thanks a lot!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top