In addition to locating a resource DLL at application startup, it is possible to switch resource DLLs dynamically at runtime. To add this functionality to your own applications, you need to include the ReInit unit in your uses statement. (ReInit is located in the Richedit sample in the Demos directory.) To switch languages, you should call LoadResourceModule, passing the LCID for the new language, and then call ReinitializeForms.
For example, the following code switches the interface language to French:
const FRENCH = (SUBLANG_FRENCH shl 10) or LANG_FRENCH; if LoadNewResourceModule(FRENCH) <> 0 then ReinitializeForms;
const FRENCH = MAKELANGID(SUBLANG_FRENCH, LANG_FRENCH); if (LoadNewResourceModule(FRENCH)) ReinitializeForms();
The advantage of this technique is that the current instance of the application and all of its forms are used. It is not necessary to update the registry settings and restart the application or re-acquire resources required by the application, such as logging in to database servers.
When you switch resource DLLs the properties specified in the new DLL overwrite the properties in the running instances of the forms.
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|