I am trying to do internationalization in a WTL GUI application .. in my drop down selection change handler (which is used for language selection I do something like this):
int selected = (int)::SendMessage(m_cbLang, CB_GETCURSEL,0,0);
HMODULE hmod;
int retCode = 0;
switch(selected)
{
case 0:
retCode =::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN, NULL, &hmod);
ATL::_AtlBaseModule.SetResourceInstance(hmod);
break;
case 1:
retCode =::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN, L"GuiLibOther.dll", &hmod);
ATL::_AtlBaseModule.SetResourceInstance(hmod);
break;
}
return S_OK;
Now, I really don't know how to use this function, although it is here , I don t know what the lpModuleName represents. The "GuiLibOther.dll" is a dll which contains the entire interface in another language.. all resources translated to another language.. I want the interface to change the language imediatelly after another language is selected. is this the right way? Case 0 return hmod = NULL
First of all you don't want to use the
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
flag unless you're passing the address of some item in the DLL, which in this case you're not.Second the documentation implies that the DLL must already be loaded before you call
GetModuleHandleEx
. If you haven't linked it in to your .exe so that it's automatically loaded, you must useLoadLibrary
.The need to use
LoadLibrary
suggests a simplification:This should let you switch resource libraries dynamically without extra overhead.