Re: multiple language support: dialog-boxes
On 18 Jun., 21:55, mfc <mfcp...@googlemail.com> wrote:
On 18 Jun., 20:41, Joseph M. Newcomer <newco...@flounder.com> wrote:
Why is there *any* button called "btn1". The FIRST thing you do when=
creating controls is
change all those stupid default IDs (e.g., IDC_BUTTON1) to something me=
aningful (e.g.
IDC_ASK_USER_FOR_NAME). Only then do you start to create variables (=
which will have
meaningful names, like c_AskUserForName) and handlers (e.g., OnBnClicke=
dAsUserForName).
So already you are digging yourself into a pit of unmaintainability.
On Fri, 18 Jun 2010 10:30:36 -0700 (PDT), mfc <mfcp...@googlemail.com> =
wrote:
Hi,
I`ve a sdi application where I want to add multiple language support.
If the user press the button btn1, the language should be changed.
After the OnButtonClick-Function I`m using SendMessage to send a msg
to one function in the mainframe-class
(class CMainFrame : public CFrameWnd)
This is the function in the CMainFrame() - only a small demo:
HINSTANCE hInst = NULL;
if(!m_hInstGerman)
m_hInstGerman = LoadLibrary(_T("LangDeu.dll"));
****
There are so many things wrong with the above code I cannot hope to lis=
t all of them.
Why is there an m_hInstGerman? Do you plan to add a variable for eac=
h of the several
hundred languages supported? Will there be an hInstItalian_Italy, hi=
nstItalian_Swiss, an
hInstSpanish_Mexican, an hInstFrench_Canadian? Of course not. One=
local instance
variable will suffice for all possible languages and that's all you sho=
uld ever need. In
the worst case, using a simple std::map to map language abbreviations t=
o DLL handles might
be used, if you want to support the user dynamically switching language=
s. Or, you can
compute the DLL name (GetModuleFileName) and only load the DLL if the n=
ame you get is
different from the one you have (don't forget to FreeLibrary the one yo=
u are about to
replace!)
Why are you not forming the name from the user's current selected activ=
e language? Why
did you hardwire it to "LangDeu.dll"?
Do you plan to add code like the above for each of the hundreds of lang=
uages supported by
Windows?
Play with my Locale Explorer (see my MVP Tips site). It will even gener=
ate the code for
you!
From the Locale Explorer:
// LOCALE_SABBREVLANGNAME
CString sabbrevlangname_data;
LCID lcid = LOCALE_SYSTEM_DEFAULT;
{ /* get LOCALE_SABBREVLANGNAME */
LPTSTR p = sabbrevlangname_data.GetBuffer(4);
VERIFY(::GetLocaleInfo(lcid, LOCALE_SABBREVLANGNAME, p, 4));
sabbrevlangname_data.ReleaseBuffer();} /* get LOCALE_SABBREVLANGNAME=
*/
// ... use sabbrevlangname_data here
thanks for all these information. Do you know which steps I`ve to do
to start a new dll (during running the programm)? Or is it only
possible to restart the programm to start a new dll???
All the steps which are necessary after loading the new dll file with
LoadLibrary()...- Zitierten Text ausblenden -
- Zitierten Text anzeigen -
I`ve found a good working example besides the effect that the language
didn`t change the dll on-the-fly
http://read.pudn.com/downloads83/sourcecode/chinese/319271/LanguageSupport.=
cpp__.htm
void CLanguageSupport::OnSwitchLanguage(UINT nId, bool
bLoadNewLanguageImmediately)
with bLoadNewLanguageImmediately = TRUE;
Everything seems to be ok, but it doesn`t work... maybe you know where
the problem would be?
best regards
Hans