Reputation: 4395
I am working on a multilingual application using VC++, MFC in visual studio. I am having separate .rc file for each language.
say
English.rc //having string table for English language
French.rc //having string table for French language
German.rc //having string table for German language
each language is having its string table maintained.
As we can use function LoadString(ID_HERE)
to get string value from string table. I want to link different language .rc file so that I can get string for different language. By default English.rc
file is associated with project. I want to know how I can change it to another .rc file using.
How can I load/link any particular language .rc file at runtime or can change language by selecting any language in dropdown box?
I don't want to use DLL method for it. Is there any direct method to link .rc file to project?
Upvotes: 1
Views: 1503
Reputation: 754
That's the way. You must create a resource dll and load the resources from it. Another way would be to have all resources as language depending conditions. Then, MFC would choose the resource based on the operating system language. But it is almost impossible to keep all languages in sync for large projects and you have no control over the displayed language.
The language resource dll works sort of like this:
HMODULE hm = ::LoadLibrary(language_dll);
if(hm)
{
AfxSetResourceHandle(hm);
if(m_hLanguageDLL)
::FreeLibrary(m_hLanguageDLL);
m_hLanguageDLL = hm;
}
Upvotes: 1